Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inside serialized item list, show if and enable if not works #377

Open
mmar58 opened this issue Nov 28, 2023 · 1 comment
Open

Inside serialized item list, show if and enable if not works #377

mmar58 opened this issue Nov 28, 2023 · 1 comment

Comments

@mmar58
Copy link

mmar58 commented Nov 28, 2023

`public class TimelineItem
{

string name = "";
public TimelineItem()
{
    
    name = "TImeline Elemenet";
}
public bool label;
[NaughtyAttributes.ShowIf("label")]
public string LabelText = "Round 1";
public List<VideoItem> videos = new List<VideoItem>();
public bool loop;
[NaughtyAttributes.ShowIf("ShouldShowLoop")]
public int loopCount=1;
public bool startTimer;
[NaughtyAttributes.ShowIf("startTimer")]
public float timerTime = 60;
bool ShouldShowLoop()
{
    return loop&&!label;
}

}
[Serializable]
public class VideoItem
{
List titles = new();
[Dropdown("titles")]
public string value;
public VideoItem() {
titles = TimelineCreator.sectionTitles;
}
}`

This is my class and I am using [SerializeField] List<TimelineItem> Timeline = new(); in the mono behavior. The dropdown is working great, no matter how deep it is. But the show if and enable if isn't working inside the list view.

So I will be greatful if you fix this issue. But I loved your work, thanks, will use it in every project I will create.

@TylerTemp
Copy link

NaughtyAttributes only works as CustomEditor and PropertyAttributeDrawer, which does not work on Serializable

A working one is here but you need to switch the decorator inside Serialieable from NA to SaintsField's version

[Serializable]
public class VideoItem
{
    // DeEditorUtils.List titles = new();
    [Dropdown("titles"), BelowRichLabel(nameof(value), true)]
    public string value;

    public DropdownList<string> titles = new DropdownList<string>
    {
        { "Example1", "Example1" },
        { "Example2", "Example2" },
        { "Example3", "Example3" },
    };

    public VideoItem() {
        // titles = TimelineCreator.sectionTitles;
    }
}

// [SaintsRow] public VideoItem[] videoItem;

[Serializable]
public class TimelineItem
{

    string name = "";
    public TimelineItem()
    {

        name = "TImeline Elemenet";
    }
    public bool label;
    [ShowIf("label")]
    public string LabelText = "Round 1";
    [SaintsRow]
    public List<VideoItem> videos = new List<VideoItem>();
    public bool loop;
    [ShowIf("ShouldShowLoop")]
    public int loopCount=1;
    public bool startTimer;
    [ShowIf("startTimer")]
    public float timerTime = 60;
    bool ShouldShowLoop()
    {
        return loop&&!label;
    }

}

[SerializeField, SaintsRow] List<TimelineItem> Timeline = new List<TimelineItem>();

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants