- edited description
Odin Selector Popups add changes to undo stack
When using a value dropdown with nested keys, selected values are getting put on the undo stack when they shouldn't be. For example, if I add this script to an empty game obect:
using System.Collections.Generic;
using Sirenix.OdinInspector;
public class ValueDropdownTest : SerializedMonoBehaviour
{
[ValueDropdown("GetValues")]
public string Test;
private List<string> GetValues()
{
return new List<string>()
{
"group",
"group2",
"group/subgroup",
"group/subgroup2",
"group2/subgroup",
"group2/subgroup2",
"group/subgroup/one",
"group/subgroup/two",
"group/subgroup/three",
"group/subgroup2/one",
"group/subgroup2/two",
"group/subgroup2/three",
"group2/subgroup/one",
"group2/subgroup/two",
"group2/subgroup/three",
"group2/subgroup2/one",
"group2/subgroup2/two",
"group2/subgroup2/three",
};
}
}
Whenever I click on one of the group or subgroup listings, even if I'm only clicking on the arrow to open or close it, it will get selected, the value will update, and an entry will get put on the undo stack even though the selector popup doesn't close. However, the release notes state:
"The enums flag and other Odin selector popups, now changes the value while the editor is open, instead of waiting until the window is closed. The values are still only applied on when the window closes so it doesn't fill up the undo stack."
Also, if I remove the first 6 entries from my list of possible values, so that it now reads:
return new List<string>()
{
"group/subgroup/one",
"group/subgroup/two",
"group/subgroup/three",
"group/subgroup2/one",
"group/subgroup2/two",
"group/subgroup2/three",
"group2/subgroup/one",
"group2/subgroup/two",
"group2/subgroup/three",
"group2/subgroup2/one",
"group2/subgroup2/two",
"group2/subgroup2/three",
};
It will set the value to null whenever I click on one of the group or subgroup items (again, even if only clicking on the open/close arrow), and a null will get put on the undo stack, though if I click multiple group/subgroups in succession, there will only be one null on the undo stack.
Comments (4)
-
reporter -
- changed status to resolved
Thanks a lot!
Clicking the triangle on OdinMenuItems now no longer selects the menu item, and only toggles the isExpanded state. Holding alt, now also expand or collapses all child menu items.
EnableSingleClickToSelect no longer changes unnecessary GUI.changed states which populates the undo stack.
-
reporter Sounds great! Is this a fix I can get by re-importing Odin, or do I need to wait for another release?
-
I'll be in the next patch 2.0.2 which we'll submit today or tomorrow hopefully.
- Log in to comment