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();
        }
Ejemplo n.º 2
0
        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();

            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();
        }