public override void OnInspectorGUI() { EditorGUILayout.Separator(); serializedObject.Update(); var parametersProperty = serializedObject.FindProperty("m_Parameters"); parametersProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.parameters, parametersProperty.isExpanded); if (parametersProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_ParameterList.AdjustElementHeight(m_ParameterList.count == 0 ? 1 : 3); m_ParameterList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } var criteriaProperty = serializedObject.FindProperty("m_Criteria"); criteriaProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.criteria, criteriaProperty.isExpanded); if (criteriaProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_CriteriaList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } EditorGUILayout.EndFoldoutHeaderGroup(); var customRewards = serializedObject.FindProperty("m_CustomTerminalRewards"); if (customRewards != null) { customRewards.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.terminalRewards, customRewards.isExpanded); if (customRewards.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_TerminalReward"), new GUIContent("Base Value")); GUILayout.Label(EditorStyleHelper.rewardModifiers); m_RewardModifiers.AdjustElementHeight(m_RewardModifiers.count == 0 ? 1 : 2); m_RewardModifiers.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }
public override void OnInspectorGUI() { var trait = (OldTraitDefinition)target; serializedObject.Update(); EditorGUILayout.Space(); m_FieldList.serializedProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.fields, m_FieldList.serializedProperty.isExpanded); if (m_FieldList.serializedProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_FieldList.AdjustElementHeight(m_FieldList.count == 0?1:3); m_FieldList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } m_ExpandAssetUsage = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.usages, m_ExpandAssetUsage); if (m_ExpandAssetUsage) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); EditorGUILayout.BeginVertical(GUI.skin.box); GUI.enabled = false; var used = IsTraitUsed(trait); GUI.enabled = true; if (!used) { GUILayout.Label("None", EditorStyles.miniLabel); } GUILayout.EndVertical(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); m_EnumList.serializedProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.values, m_EnumList.serializedProperty.isExpanded); if (m_EnumList.serializedProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_EnumList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); var parametersProperty = serializedObject.FindProperty("m_Parameters"); parametersProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.parameters, parametersProperty.isExpanded, AIPlannerPreferences.displayActionDefinitionAdvancedSettings, toggle => AIPlannerPreferences.displayActionDefinitionAdvancedSettings = toggle); if (parametersProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); if (m_ParameterList.count >= ActionKey.MaxLength) { EditorGUILayout.HelpBox(EditorStyleHelper.maxParametersReached); } m_ParameterList.AdjustElementHeight(m_ParameterList.count == 0 ? 1 : AIPlannerPreferences.displayActionDefinitionAdvancedSettings?4:3); m_ParameterList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } m_PreconditionList.serializedProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.preconditions, m_PreconditionList.serializedProperty.isExpanded); if (m_PreconditionList.serializedProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_PreconditionList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } m_ObjectCreatedList.serializedProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.effects, m_ObjectCreatedList.serializedProperty.isExpanded); if (m_ObjectCreatedList.serializedProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); GUILayout.Label(EditorStyleHelper.objectsCreated); m_ObjectCreatedList.AdjustElementHeight(m_ObjectCreatedList.count == 0 ? 1 : 2); m_ObjectCreatedList.DoLayoutList(); GUILayout.Label(EditorStyleHelper.objectsChanged); m_ObjectModifierList.DoLayoutList(); GUILayout.Label(EditorStyleHelper.objectsRemoved); m_ObjectRemovedList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } var customRewards = serializedObject.FindProperty("m_CustomRewards"); customRewards.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.rewards, customRewards.isExpanded); if (customRewards.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Reward"), new GUIContent("Base Value")); GUILayout.Label(EditorStyleHelper.rewardModifiers); m_RewardModifierList.AdjustElementHeight(m_RewardModifierList.count == 0 ? 1 : 2); m_RewardModifierList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }
public override void OnInspectorGUI() { serializedObject.Update(); m_ActionList.serializedProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.actions, m_ActionList.serializedProperty.isExpanded); if (m_ActionList.serializedProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_ActionList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } m_TerminationList.serializedProperty.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.terminations, m_TerminationList.serializedProperty.isExpanded); if (m_TerminationList.serializedProperty.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); m_TerminationList.DoLayoutList(); GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } var customCumulativeRewardEstimator = serializedObject.FindProperty("m_CustomCumulativeRewardEstimator"); customCumulativeRewardEstimator.isExpanded = EditorStyleHelper.DrawSubHeader(EditorStyleHelper.plannerSettings, customCumulativeRewardEstimator.isExpanded, AIPlannerPreferences.displayProblemDefinitionAdvancedSettings, value => AIPlannerPreferences.displayProblemDefinitionAdvancedSettings = value); if (customCumulativeRewardEstimator.isExpanded) { GUILayout.Space(EditorStyleHelper.subHeaderPaddingTop); var rewardEstimatorTypeNames = PlannerCustomTypeCache.CumulativeRewardEstimatorTypes.Select(t => t.FullName).Prepend(string.Empty).ToArray(); var rewardEstimatorTypeShortNames = PlannerCustomTypeCache.CumulativeRewardEstimatorTypes.Select(t => t.Name).Prepend(k_Default).ToArray(); var rewardEstimatorIndex = Array.IndexOf(rewardEstimatorTypeNames, customCumulativeRewardEstimator.stringValue); EditorGUI.BeginChangeCheck(); if (rewardEstimatorIndex == -1 && !string.IsNullOrEmpty(customCumulativeRewardEstimator.stringValue)) { GUI.backgroundColor = Color.red; rewardEstimatorTypeShortNames = rewardEstimatorTypeShortNames.Append($"Unknown type {customCumulativeRewardEstimator.stringValue}").ToArray(); rewardEstimatorIndex = rewardEstimatorTypeShortNames.Length - 1; } rewardEstimatorIndex = EditorGUILayout.Popup(EditorStyleHelper.cumulativeRewardEstimator, rewardEstimatorIndex, rewardEstimatorTypeShortNames); if (EditorGUI.EndChangeCheck()) { if (rewardEstimatorIndex < rewardEstimatorTypeNames.Length) { customCumulativeRewardEstimator.stringValue = rewardEstimatorTypeNames[rewardEstimatorIndex]; } } GUI.backgroundColor = Color.white; if (rewardEstimatorIndex == 0) { EditorGUILayout.BeginHorizontal(); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PrefixLabel("Bounds"); } var lowerEstimate = serializedObject.FindProperty("m_DefaultEstimateLower"); var averageEstimate = serializedObject.FindProperty("m_DefaultEstimateAverage"); var upperEstimate = serializedObject.FindProperty("m_DefaultEstimateUpper"); lowerEstimate.intValue = EditorGUILayout.IntField(lowerEstimate.intValue); averageEstimate.intValue = EditorGUILayout.IntField(averageEstimate.intValue); upperEstimate.intValue = EditorGUILayout.IntField(upperEstimate.intValue); EditorGUILayout.EndHorizontal(); } if (AIPlannerPreferences.displayProblemDefinitionAdvancedSettings) { var discountFactor = serializedObject.FindProperty("DiscountFactor"); EditorGUILayout.PropertyField(discountFactor); } GUILayout.Space(EditorStyleHelper.subHeaderPaddingBottom); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }