浏览代码

Disable target property when no compatible properties and set default target enums

/main
Steven Leal 4 年前
当前提交
f572b044
共有 2 个文件被更改,包括 21 次插入13 次删除
  1. 30
      com.unity.perception/Editor/Randomization/ParameterElement.cs
  2. 4
      com.unity.perception/Runtime/Randomization/Parameters/ParameterTarget.cs

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


targetField.RegisterCallback<ChangeEvent<Object>>(evt =>
{
ClearTarget();
var appFreqEnumIndex = m_ApplicationFrequency.enumValueIndex;
var appFreqEnumIndex = m_ApplicationFrequency.intValue;
m_ApplicationFrequency.enumValueIndex = appFreqEnumIndex;
m_ApplicationFrequency.intValue = appFreqEnumIndex;
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
ToggleTargetContainer();
FillPropertySelectMenu();

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_Target.FindPropertyRelative("fieldOrProperty").intValue = (int)newTarget.fieldOrProperty;
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
m_TargetPropertyMenu.text = TargetPropertyDisplayText(parameter.target);
}

return;
m_TargetPropertyMenu.menu.MenuItems().Clear();
m_TargetPropertyMenu.text = parameter.target.propertyName == string.Empty
? "Select a property"
: TargetPropertyDisplayText(parameter.target);
foreach (var option in options)
if (options.Count == 0)
m_TargetPropertyMenu.menu.AppendAction(
TargetPropertyDisplayText(option),
a => { SetTarget(option); });
m_TargetPropertyMenu.text = "No compatible properties";
m_TargetPropertyMenu.SetEnabled(false);
}
else
{
m_TargetPropertyMenu.SetEnabled(true);
foreach (var option in options)
{
m_TargetPropertyMenu.menu.AppendAction(
TargetPropertyDisplayText(option),
a => { SetTarget(option); });
}
m_TargetPropertyMenu.text = parameter.target.propertyName == string.Empty
? "Select a property"
: TargetPropertyDisplayText(parameter.target);
}
}

4
com.unity.perception/Runtime/Randomization/Parameters/ParameterTarget.cs


[SerializeField] internal GameObject gameObject;
[SerializeField] internal Component component;
[SerializeField] internal string propertyName = "";
[SerializeField] internal FieldOrProperty fieldOrProperty;
[SerializeField] internal ParameterApplicationFrequency applicationFrequency;
[SerializeField] internal FieldOrProperty fieldOrProperty = FieldOrProperty.Field;
[SerializeField] internal ParameterApplicationFrequency applicationFrequency = ParameterApplicationFrequency.OnIterationSetup;
/// <summary>
/// Assigns a new target

正在加载...
取消
保存