ReadOnly

  06. Attributes No Comments

When added before a class member makes it be drawn as a non-editable read-only control in the inspector.

Attribute Target

Field, property, method or indexer.

Example

using Sisus.Attributes;
using UnityEngine;

namespace Sisus.Testing
{
	public class Chase : MonoBehaviour
	{
		// Show in inspector but don't allow changing the value
		[ShowInInspector, ReadOnly]
		internal Transform ChaseTarget
		{
			get;
			set;
		}

		// Called every frame
		void Update()
		{
			if(ChaseTarget != null)
			{
				transform.position = Vector3.MoveTowards(transform.position, ChaseTarget.position, Time.deltaTime);
			}
		}
	}
}

Example Result