Hide
SaintsRow

SaintsRow attribute allows you to draw Button, Layout, ShowInInspector, DOTweenPlay etc. (all SaintsEditor specific attributes) in a Serializable object (usually a class or a struct).

Tip
If you've enabled SaintsEditor, you do not need this attribute at all. It'll kickin by default.

Parameters:

  • bool inline=false

    If true, it'll draw the Serializable inline like it's directly in the MonoBehavior

  • Allow Multiple: No

Special Note:

After applying this attribute, only pure PropertyDrawer, and decorators from SaintsEditor works on this target. Which means, using third party's PropertyDrawer is fine, but decorator of Editor level (e.g. Odin's Button, NaughtyAttributes' Button) will not work.

using SaintsField; using SaintsField.Playa; // SaintsEditor is not required here [Serializable] public struct Nest { public string nest2Str; // normal field [Button] // function button private void Nest2Btn() => Debug.Log("Call Nest2Btn"); // static field (non serializable) [ShowInInspector] public static Color StaticColor => Color.cyan; // const field (non serializable) [ShowInInspector] public const float Pi = 3.14f; // normal attribute drawer works as expected [BelowImage(maxWidth: 25)] public SpriteRenderer spriteRenderer; [DOTweenPlay] // DOTween helper private Sequence PlayColor() { return DOTween.Sequence() .Append(spriteRenderer.DOColor(Color.red, 1f)) .Append(spriteRenderer.DOColor(Color.green, 1f)) .Append(spriteRenderer.DOColor(Color.blue, 1f)) .SetLoops(-1); } [DOTweenPlay("Position")] private Sequence PlayTween2() { return DOTween.Sequence() .Append(spriteRenderer.transform.DOMove(Vector3.up, 1f)) .Append(spriteRenderer.transform.DOMove(Vector3.right, 1f)) .Append(spriteRenderer.transform.DOMove(Vector3.down, 1f)) .Append(spriteRenderer.transform.DOMove(Vector3.left, 1f)) .Append(spriteRenderer.transform.DOMove(Vector3.zero, 1f)) ; } } [SaintsRow] public Nest n1;

saints_row

To show a Serializable inline like it's directly in the MonoBehavior:

using SaintsField; [Serializable] public struct MyStruct { public int structInt; public bool structBool; } [SaintsRow(inline: true)] public MyStruct myStructInline; public string normalStringField;

saints_row_inline

SerializeReference

SaintsRow can work on SerializeReference. If using it together with ReferencePicker, ensure ReferencePicker is before SaintsRow!

using SaintsField; public interface IRefInterface { public int TheInt { get; } } [Serializable] public struct StructImpl : IRefInterface { [field: SerializeField] public int TheInt { get; set; } [LayoutStart("Hi", ELayout.FoldoutBox)] public string myStruct; public ClassDirect nestedClass; } [SerializeReference, ReferencePicker, SaintsRow] public IRefInterface saints; [SerializeReference, ReferencePicker(hideLabel: true), SaintsRow(inline: true)] public IRefInterface inline;

image

Drawer

alternatively, you can make a drawer for your data type to omit [SaintsRow] everywhere:

using SaintsField.Editor.Playa; [CustomPropertyDrawer(typeof(Nest))] public class MySaintsRowAttributeDrawer: SaintsRowAttributeDrawer {}