Skip to content

FoldoutGroup does not remember its state while selecting and unselecting similar objects in Hierarchy #161

Description

@jpetays

I have four FoldoutGroups and their collapsed and expanded states behaves erratically when I switch selection from one object to an other or use multiselection and single selection.

AFAIK UNITY Inspector remembers collapsed and expanded states (for applicable objects, like arrays or [Serializable] objects) perfectly.

For my case it seems that two lowest FoldoutGroups ("Highlight Sprites" and "Pickup Image") work perfectly but the other two do not. They are losing their collapsed/expanded state when selection changes between different objects in Hierarchy.

For my project this is absolute no-go while evaluating to switch to Alchemy as you might loose some important UNITY Editor/Inspector quality of life features!

using Alchemy.Inspector;
using UnityEngine;
using UnityEngine.UIElements;

public class TestAttributes : MonoBehaviour
{
#if UNITY_EDITOR
    public bool CanBeStatic => _effectAnimator == null && _audioSource == null;
    public bool IsNotStatic => !_isStaticEffect;
#endif
    private const HelpBoxMessageType None = HelpBoxMessageType.None;

    private const string I1 = "Static Effect is when there is no Animator or AudioSource";
    private const string I2 = "For looping effects there can be some (random) delay between animations.\r\n" +
                              "This is controlled by 'some other' settings how this works.";
    private const string I3 = "Plays along main Effect Animator";

    [Title("Static Effect"), HelpBox(I1, None), EnableIf("CanBeStatic"), SerializeField] private bool _isStaticEffect;

    [FoldoutGroup("Animator"), EnableIf("IsNotStatic"), SerializeField] private Animator _effectAnimator;
    [FoldoutGroup("Animator"), SerializeField] private bool _effectAnimatorRandomLoopDelay;
    [FoldoutGroup("Animator"), HelpBox(I2, None), ReadOnly, SerializeField] private float _waitBetweenEffectPlay;
    [FoldoutGroup("Animator"), HelpBox(I3, None), SerializeField] private Animator _childAnimator;

    [FoldoutGroup("Audio"), EnableIf("IsNotStatic"), SerializeField] private AudioSource _audioSource;
    [FoldoutGroup("Audio"), SerializeField] private bool _isAudioRandomizer;
    [FoldoutGroup("Audio"), SerializeField] private bool _isAudioPitchRandomizer;
    [FoldoutGroup("Audio"), SerializeField] private AudioClip[] _audioAudioClips;
    [FoldoutGroup("Audio"), ReadOnly, SerializeField] private int _currentAudioClipIndex;
    [FoldoutGroup("Audio"), ReadOnly, SerializeField] private float _currentAudioPitch = 1f;

    private const string H1 = "Highlight Sprites for Dash";
    private const string L1 = "Normal Sprite (green)";
    private const string L2 = "Blocked Sprite (red)";

    [FoldoutGroup("Highlight Sprites"), HelpBox(H1, None), LabelText(L1), SerializeField] private SpriteRenderer _animHighlightNormal;
    [FoldoutGroup("Highlight Sprites"), LabelText(L2), SerializeField] private SpriteRenderer _animHighlightBlocked;

    private const string P1 = "Pickup Image:\r\n" +
                              " * for Idle animation (can be replaced with NigthmareZone variant)\r\n" +
                              " * for Consumed state";

    [FoldoutGroup("Pickup Image"), HelpBox(P1, None), SerializeField] private SpriteRenderer _pickupImage;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions