46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |