Hide
RequireType

Allow you to specify the required component(s) or interface(s) for a field.

If the signed field does not meet the requirement, it'll:

  • show an error message, if freeSign=false
  • prevent the change, if freeSign=true

customPicker will allow you to pick an object which are already meet the requirement(s).

Overload:

  • RequireTypeAttribute(bool freeSign = false, bool customPicker = true, params Type[] requiredTypes)
  • RequireTypeAttribute(bool freeSign, params Type[] requiredTypes)
  • RequireTypeAttribute(EPick editorPick, params Type[] requiredTypes)
  • RequireTypeAttribute(params Type[] requiredTypes)

For each argument:

  • bool freeSign=false

    If true, it'll allow you to assign any object to this field, and display an error message if it does not meet the requirement(s).

    Otherwise, it will try to prevent the change.

  • bool customPicker=true

    Show a custom picker to pick an object. The showing objects are already meet the requirement(s).

  • EPick editorPick=EPick.Assets | EPick.Scene

    The picker type for the custom picker. EPick.Assets for assets, EPick.Scene for scene objects.

  • params Type[] requiredTypes

    The required component(s) or interface(s) for this field.

  • AllowMultiple: No

using SaintsField; public interface IMyInterface {} public class MyInter1: MonoBehaviour, IMyInterface {} public class MySubInter: MyInter1 {} public class MyInter2: MonoBehaviour, IMyInterface {} [RequireType(typeof(IMyInterface))] public SpriteRenderer interSr; [RequireType(typeof(IMyInterface), typeof(SpriteRenderer))] public GameObject interfaceGo; [RequireType(true, typeof(IMyInterface))] public SpriteRenderer srNoPickerFreeSign; [RequireType(true, typeof(IMyInterface))] public GameObject goNoPickerFreeSign;

RequireType