82 lines
1.3 KiB
C#
82 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
public class FreezeTransform : MonoBehaviour
|
|
{
|
|
public bool positionY;
|
|
|
|
public bool rotationX;
|
|
|
|
public bool rotationY;
|
|
|
|
public bool rotationZ;
|
|
|
|
public bool local = true;
|
|
|
|
public bool dontUpdatePosition;
|
|
|
|
public Vector3 startPosition = Vector3.zero;
|
|
|
|
[HideInInspector]
|
|
public Vector3 startRotation = Vector3.zero;
|
|
|
|
private void Awake()
|
|
{
|
|
if (local)
|
|
{
|
|
startRotation = base.transform.localEulerAngles;
|
|
}
|
|
else
|
|
{
|
|
startRotation = base.transform.eulerAngles;
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
Vector3 zero = Vector3.zero;
|
|
Vector3 zero2 = Vector3.zero;
|
|
if (local)
|
|
{
|
|
zero = base.transform.localEulerAngles;
|
|
zero2 = base.transform.localPosition;
|
|
}
|
|
else
|
|
{
|
|
zero = base.transform.eulerAngles;
|
|
zero2 = base.transform.position;
|
|
}
|
|
if (positionY)
|
|
{
|
|
zero2.y = startPosition.y;
|
|
}
|
|
if (rotationX)
|
|
{
|
|
zero.x = startRotation.x;
|
|
}
|
|
if (rotationY)
|
|
{
|
|
zero.y = startRotation.y;
|
|
}
|
|
if (rotationZ)
|
|
{
|
|
zero.z = startRotation.z;
|
|
}
|
|
if (local)
|
|
{
|
|
base.transform.localEulerAngles = zero;
|
|
if (!dontUpdatePosition)
|
|
{
|
|
base.transform.localPosition = zero2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
base.transform.eulerAngles = zero;
|
|
if (!dontUpdatePosition)
|
|
{
|
|
base.transform.position = zero2;
|
|
}
|
|
}
|
|
}
|
|
}
|