浏览代码

Persists target application frequency when changing targets

/main
Steven Leal 4 年前
当前提交
1779f534
共有 1 个文件被更改,包括 18 次插入13 次删除
  1. 31
      com.unity.perception/Editor/Randomization/ParameterElement.cs

31
com.unity.perception/Editor/Randomization/ParameterElement.cs


VisualElement m_TargetContainer;
ToolbarMenu m_TargetPropertyMenu;
SerializedProperty m_SerializedProperty;
SerializedProperty m_TargetGameObjectProperty;
SerializedProperty m_Target;
SerializedProperty m_TargetGameObject;
SerializedProperty m_ApplicationFrequency;
const string k_CollapsedParameterClass = "collapsed-parameter";

m_TargetContainer = this.Q<VisualElement>("target-container");
m_TargetPropertyMenu = this.Q<ToolbarMenu>("property-select-menu");
m_TargetGameObjectProperty = m_SerializedProperty.FindPropertyRelative("target.gameObject");
m_Target = m_SerializedProperty.FindPropertyRelative("target");
m_TargetGameObject = m_Target.FindPropertyRelative("gameObject");
frequencyField.BindProperty(m_SerializedProperty.FindPropertyRelative("target.applicationFrequency"));
m_ApplicationFrequency = m_Target.FindPropertyRelative("applicationFrequency");
frequencyField.BindProperty(m_ApplicationFrequency);
targetField.value = m_TargetGameObjectProperty.objectReferenceValue;
targetField.value = m_TargetGameObject.objectReferenceValue;
m_TargetGameObjectProperty.objectReferenceValue = (GameObject)evt.newValue;
var appFreqEnumIndex = m_ApplicationFrequency.enumValueIndex;
m_TargetGameObject.objectReferenceValue = (GameObject)evt.newValue;
m_ApplicationFrequency.enumValueIndex = appFreqEnumIndex;
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
ToggleTargetContainer();
FillPropertySelectMenu();

void ToggleTargetContainer()
{
m_TargetContainer.style.display = m_TargetGameObjectProperty.objectReferenceValue == null
m_TargetContainer.style.display = m_TargetGameObject.objectReferenceValue == null
? new StyleEnum<DisplayStyle>(DisplayStyle.None)
: new StyleEnum<DisplayStyle>(DisplayStyle.Flex);
}

m_SerializedProperty.FindPropertyRelative("target.component").objectReferenceValue = null;
m_SerializedProperty.FindPropertyRelative("target.propertyName").stringValue = string.Empty;
m_SerializedProperty.FindPropertyRelative("target.applicationFrequency").enumValueIndex = 0;
m_Target.FindPropertyRelative("component").objectReferenceValue = null;
m_Target.FindPropertyRelative("propertyName").stringValue = string.Empty;
m_SerializedProperty.FindPropertyRelative("target.gameObject").objectReferenceValue = newTarget.gameObject;
m_SerializedProperty.FindPropertyRelative("target.component").objectReferenceValue = newTarget.component;
m_SerializedProperty.FindPropertyRelative("target.propertyName").stringValue = newTarget.propertyName;
m_SerializedProperty.FindPropertyRelative("target.fieldOrProperty").enumValueIndex = (int)newTarget.fieldOrProperty;
m_TargetGameObject.objectReferenceValue = newTarget.gameObject;
m_Target.FindPropertyRelative("component").objectReferenceValue = newTarget.component;
m_Target.FindPropertyRelative("propertyName").stringValue = newTarget.propertyName;
m_Target.FindPropertyRelative("fieldOrProperty").enumValueIndex = (int)newTarget.fieldOrProperty;
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
m_TargetPropertyMenu.text = TargetPropertyDisplayText(parameter.target);
}

正在加载...
取消
保存