浏览代码

Merge pull request #129 from Unity-Technologies/randomizer-list-undo

Added undo callback to refresh randomizer list UI
/main
GitHub 4 年前
当前提交
e7f77a20
共有 2 个文件被更改,包括 13 次插入0 次删除
  1. 2
      com.unity.perception/CHANGELOG.md
  2. 11
      com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerList.cs

2
com.unity.perception/CHANGELOG.md


Corrupted .meta files have been rebuilt and replaced
The randomizer list inspector UI now updates appropriately when a user clicks undo
## [0.5.0-preview.1] - 2020-10-14
### Known Issues

11
com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerList.cs


ToolbarMenu m_AddRandomizerMenu;
public HashSet<Type> randomizerTypeSet = new HashSet<Type>();
int m_PreviousListSize;
ScenarioBase scenario => (ScenarioBase)m_Property.serializedObject.targetObject;
VisualElement inspectorContainer

collapseAllButton.clicked += () => CollapseRandomizers(true);
RefreshList();
Undo.undoRedoPerformed += () =>
{
m_Property.serializedObject.Update();
RefreshList();
};
}
void RefreshList()

randomizerTypeSet.Clear();
foreach (var randomizer in scenario.randomizers)
randomizerTypeSet.Add(randomizer.GetType());
m_PreviousListSize = m_Property.arraySize;
Undo.RegisterCompleteObjectUndo(m_Property.serializedObject.targetObject, "Add Randomizer");
var newRandomizer = scenario.CreateRandomizer(randomizerType);
newRandomizer.RandomizeParameterSeeds();
m_Property.serializedObject.Update();

public void RemoveRandomizer(RandomizerElement element)
{
Undo.RegisterCompleteObjectUndo(m_Property.serializedObject.targetObject, "Remove Randomizer");
scenario.RemoveRandomizer(element.randomizerType);
m_Property.serializedObject.Update();
RefreshList();

{
if (currentIndex == nextIndex)
return;
Undo.RegisterCompleteObjectUndo(m_Property.serializedObject.targetObject, "Reorder Randomizer");
scenario.ReorderRandomizer(currentIndex, nextIndex);
m_Property.serializedObject.Update();
RefreshList();

正在加载...
取消
保存