TylerTemp / SaintsField

A Unity Inspector extension tool focusing on script fields inspector enhancement
MIT License
154 stars 9 forks source link

[PlayaShowIf]... not work in nested class #6

Closed ZeroUltra closed 6 months ago

ZeroUltra commented 6 months ago
using SaintsField.Playa;
using UnityEngine;

public class NewMonoBehaviour : MonoBehaviour
{
    public bool boolValue;

    [PlayaShowIf(nameof(boolValue))] public int[] showIf;

    public TestClass testClass;

    [System.Serializable]
    public class TestClass
    {
        public bool boolValue;

        [PlayaShowIf(nameof(boolValue))] public int[] showIf;
    }
}

image image

Is there something wrong with my settings?

TylerTemp commented 6 months ago

SaintsEditor only works for UnityEngine.Object. Use SaintsRow to apply on a generic serializable target:

using SaintsField.Playa;
using UnityEngine;

namespace SaintsField.Samples.Scripts.IssueAndTesting.Issue
{
    public class Issue6 : MonoBehaviour
    {
        public bool boolValue;

        [PlayaShowIf(nameof(boolValue))] public int[] showIf;

        [System.Serializable]
        public class TestClass
        {
            public bool boolValue;

            [PlayaShowIf(nameof(boolValue))] public int[] showIf;
        }

        [SaintsRow] public TestClass testClass;
    }
}

image

image

Special Note:

  1. After applied 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.
  2. IMGUI: ELayout.Horizontal does not work here
  3. IMGUI: DOTweenPlay might be a bit buggy displaying the playing/pause/stop status for each function.
ZeroUltra commented 6 months ago

You're my hero.