You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
479 B
C#
24 lines
479 B
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("Malbers/Utilities/Tools/Lock Axis")]
|
|
|
|
public class LockAxis : MonoBehaviour
|
|
{
|
|
public bool LockX = true;
|
|
public bool LockY = false;
|
|
public bool LockZ = false;
|
|
|
|
public Vector3 LockOffset;
|
|
|
|
void Update()
|
|
{
|
|
Vector3 pos = transform.position;
|
|
|
|
if (LockX) pos.x = LockOffset.x;
|
|
if (LockY) pos.y = LockOffset.y;
|
|
if (LockZ) pos.z = LockOffset.z;
|
|
|
|
transform.position = pos;
|
|
}
|
|
}
|