更改了文件结构
This commit is contained in:
46
Src/Unity/Scripts/Components/SetRotation.cs
Normal file
46
Src/Unity/Scripts/Components/SetRotation.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SetRotation : Provider
|
||||
{
|
||||
public Transform root;
|
||||
public bool isLocal;
|
||||
public Vector3 weight;
|
||||
public Vector3 defaultEulur;
|
||||
void Awake()
|
||||
{
|
||||
defaultEulur = isLocal ? transform.localEulerAngles : transform.eulerAngles;
|
||||
}
|
||||
public override void Set<T>(T obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case float _float:
|
||||
_SetRotation(Quaternion.Euler(defaultEulur + weight * _float));
|
||||
break;
|
||||
case Vector3 _vector3:
|
||||
_SetRotation(Quaternion.Euler(_vector3));
|
||||
break;
|
||||
case Quaternion quaternion:
|
||||
_SetRotation(quaternion);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void _SetRotation(Quaternion eulur)
|
||||
{
|
||||
if (root)
|
||||
{
|
||||
if (isLocal)
|
||||
{
|
||||
root.localRotation = eulur;
|
||||
}
|
||||
else
|
||||
{
|
||||
root.rotation = eulur;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user