1
This commit is contained in:
58
Src/Unity/Scripts/Transform/UnityTransform.cs
Normal file
58
Src/Unity/Scripts/Transform/UnityTransform.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public static class TransformExtensions
|
||||
{
|
||||
public static UnityTransform ToUnityTransform(this Transform transform)
|
||||
{
|
||||
return new UnityTransform(transform);
|
||||
}
|
||||
}
|
||||
public readonly struct UnityTransform:ITransform
|
||||
{
|
||||
private readonly Transform _transform;
|
||||
public UnityTransform(Transform transform)
|
||||
{
|
||||
_transform = transform;
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_transform)
|
||||
Object.Destroy(_transform.gameObject);
|
||||
}
|
||||
|
||||
public float3 LocalPosition
|
||||
{
|
||||
get => _transform.localPosition;
|
||||
set => _transform.localPosition = value;
|
||||
}
|
||||
public float3 Position
|
||||
{
|
||||
get => _transform.position;
|
||||
set => _transform.position = value;
|
||||
}
|
||||
public quaternion LocalRotation
|
||||
{
|
||||
get => _transform.localRotation;
|
||||
set => _transform.localRotation = value;
|
||||
}
|
||||
public quaternion Rotation
|
||||
{
|
||||
get => _transform.rotation;
|
||||
set => _transform.rotation = value;
|
||||
}
|
||||
public float3 LocalScale
|
||||
{
|
||||
get => _transform.localScale;
|
||||
set => _transform.localScale = value;
|
||||
}
|
||||
public float4x4 Matrix
|
||||
{
|
||||
get =>new float4x4(_transform);
|
||||
set => _transform.SetPositionAndRotation(value.c3.xyz,quaternion.LookRotation(value.c2.xyz,value.c1.xyz));
|
||||
}
|
||||
}
|
||||
}
|
11
Src/Unity/Scripts/Transform/UnityTransform.cs.meta
Normal file
11
Src/Unity/Scripts/Transform/UnityTransform.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00ca8f0448c743b46aca4d8ae497db31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user