LockTransform

  06. Attributes No Comments

When added before a component class causes the transform component to be locked to default state in the inspector for all GameObjects that contain the component with this attribute.

This means that the local position and rotation of the transform will always remain at (0, 0, 0), and the local scale will always remain at (1, 1, 1) as long as the GameObject is shown in the inspector.

This does not prevent the transform from being modified outside of the inspector.

Attribute Target

Component class

Example

using UnityEngine;
using Sisus.Attributes;

[LockTransform, ExecuteAlways]
public class TransformLock : MonoBehaviour
{
	[HelpBox("This transform has been locked to prevent it from being modified.")]
	[Button]
	private void Unlock()
	{
		DestroyImmediate(this);
	}
}