Skip to content

Commit

Permalink
Added Randomizers and RandomizerTags
Browse files Browse the repository at this point in the history
  • Loading branch information
sleal-unity committed Oct 2, 2020
1 parent 4e70bb0 commit 964300e
Show file tree
Hide file tree
Showing 122 changed files with 2,113 additions and 1,446 deletions.
3 changes: 3 additions & 0 deletions com.unity.perception.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

8 changes: 8 additions & 0 deletions com.unity.perception/Editor/Randomization/Editors.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.Experimental.Perception.Randomization.Scenarios;
using UnityEngine.Experimental.Perception.Randomization.VisualElements;
using UnityEngine.UIElements;

namespace UnityEngine.Experimental.Perception.Randomization.Editor
Expand All @@ -13,6 +14,7 @@ class ScenarioBaseEditor : UnityEditor.Editor
VisualElement m_Root;
VisualElement m_InspectorPropertiesContainer;
VisualElement m_ConstantsContainer;
VisualElement m_RandomizerListPlaceholder;
SerializedProperty m_ConstantsProperty;

public override VisualElement CreateInspectorGUI()
Expand All @@ -21,15 +23,18 @@ public override VisualElement CreateInspectorGUI()
m_SerializedObject = new SerializedObject(m_Scenario);
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/ScenarioBaseElement.uxml").CloneTree();
CreatePropertyFields();
CheckIfConstantsExist();

var serializeConstantsButton = m_Root.Query<Button>("serialize-constants").First();
var serializeConstantsButton = m_Root.Q<Button>("serialize-constants");
serializeConstantsButton.clicked += () => m_Scenario.Serialize();

var deserializeConstantsButton = m_Root.Query<Button>("deserialize-constants").First();
var deserializeConstantsButton = m_Root.Q<Button>("deserialize-constants");
deserializeConstantsButton.clicked += () => m_Scenario.Deserialize();

m_RandomizerListPlaceholder = m_Root.Q<VisualElement>("randomizer-list-placeholder");

CreatePropertyFields();
CheckIfConstantsExist();

return m_Root;
}

Expand All @@ -44,20 +49,24 @@ void CreatePropertyFields()
{
do
{
if (iterator.name == "m_Script")
{
// Skip this property
}
else if (iterator.name == "constants")
{
m_ConstantsProperty = iterator.Copy();
}
else
switch (iterator.name)
{
foundProperties = true;
var propertyField = new PropertyField(iterator.Copy());
propertyField.Bind(m_SerializedObject);
m_InspectorPropertiesContainer.Add(propertyField);
case "m_Script":
break;
case "constants":
m_ConstantsProperty = iterator.Copy();
break;
case "m_Randomizers":
m_RandomizerListPlaceholder.Add(new RandomizerList(iterator.Copy()));
break;
default:
{
foundProperties = true;
var propertyField = new PropertyField(iterator.Copy());
propertyField.Bind(m_SerializedObject);
m_InspectorPropertiesContainer.Add(propertyField);
break;
}
}
} while (iterator.NextVisible(false));
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 964300e

Please sign in to comment.