Category : 06. Attributes

Base class for attributes that can be used to override the default data validation logic for the target. Implements IValueValidator and ITargetableAttribute interfaces. Attribute Target Field, property, indexer, method return value or method parameter. Example using System; using System.Collections.Generic; using System; using UnityEngine; namespace Sisus.Attributes { /// <summary> /// Attribute that specifies that its target ..

Read more

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 { ..

Read more

When added before a component class will make sure that whenever the component with the attribute is added to GameObjects, at least one component matching one of the specified types is also present on the same GameObject. Attribute Target Component class Example using System; using UnityEngine; using UnityEngine.UI; using Sisus.Attributes; [RequireAnyComponent(typeof(Renderer), typeof(Graphic)), DisallowMultipleComponent] public class ..

Read more

When added before a component class prevents other components (besides the transform component) from being added into GameObjects that contain the component with this attribute. Attribute Target Component class Example using UnityEngine; using Sisus.Attributes; [OnlyComponent] public class LonelyComponent : MonoBehaviour { [ShowInInspector] const bool alone = true; } Exam..

Read more

When added before a component class causes the transform component to be hidden inside the inspector view for all GameObjects that contain the component with this attribute. Attribute Target Component class Example using UnityEngine; using Sisus.Attributes; [HideTransformInInspector, DisallowMultipleComponent] public class ReadOnlyTransform : MonoBehaviour { [ShowInInspector] public Vector3 Position { get { return transform.localPosition; } } ..

Read more

When added before a component class causes the component to be hidden inside the inspector view. Attribute Target Component class Example using UnityEngine; using Sisus.Attributes; [HideComponentInInspector] public class MyHiddenComponent : MonoBehaviour { void Start() { Debug.Log(“You can’t see me!”, this); } } Exam..

Read more