示例#1
0
        public void OnInspectorEnabled(SerializedObject m_ParentObject)
        {
            SerializedObject m_Object = new SerializedObject(this);

            AIBehaviorsAnimationEditorGUI.OnInspectorEnabled(m_ParentObject, m_Object);

            OnStateInspectorEnabled(m_ParentObject);
        }
示例#2
0
        protected override void DrawStateInspectorEditor(SerializedObject m_State, AIBehaviors fsm)
        {
            SerializedProperty m_property;

            string[] animNames          = AIBehaviorsAnimationEditorGUI.GetAnimationStateNames(m_State);
            int      curAttackAnimIndex = 0;

            for (int i = 0; i < animNames.Length; i++)
            {
                if (animNames[i] == animationStates[0].name)
                {
                    curAttackAnimIndex = i;
                }
            }

            GUILayout.Label("Attack Properties:", EditorStyles.boldLabel);

            GUILayout.BeginVertical(GUI.skin.box);

            m_property = m_State.FindProperty("attackDamage");
            EditorGUILayout.PropertyField(m_property);

            EditorGUILayout.Separator();

            // Movement Settings

            GUILayout.Label("Movement Settings:", EditorStyles.boldLabel);

            m_property = m_State.FindProperty("inheritPreviousStateMovement");
            EditorGUILayout.PropertyField(m_property);

            EditorGUILayout.Separator();

            // Animation Settings

            GUILayout.Label("Animation Settings:", EditorStyles.boldLabel);

            m_property = m_State.FindProperty("attackPoint");
            EditorGUILayout.Slider(m_property, 0.0f, 1.0f);

            if (!Application.isPlaying)
            {
                if (curAttackAnimIndex != -1 && curAttackAnimIndex < animNames.Length)
                {
                    float calcAttackTime = SampleAttackAnimation(fsm, animNames[curAttackAnimIndex], m_property.floatValue);

                    m_property            = m_State.FindProperty("animAttackTime");
                    m_property.floatValue = calcAttackTime;
                }
            }

            EditorGUILayout.Separator();

            // === Reload Properties === //

            GUILayout.Label("Reload Settings:", EditorStyles.boldLabel);

            m_property = m_State.FindProperty("attacksBeforeReload");
            EditorGUILayout.PropertyField(m_property, new GUIContent("Attacks Before Reload"));

            m_property = m_State.FindProperty("attackCount");
            EditorGUILayout.PropertyField(m_property, new GUIContent("Attack count (of " + attacksBeforeReload + ")"));

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Reload State:");
                m_property = m_State.FindProperty("reloadState");
                m_property.objectReferenceValue = AIBehaviorsStatePopups.DrawEnabledStatePopup(fsm, m_property.objectReferenceValue as BaseState);

                if (reloadState == null)
                {
                    m_property.objectReferenceValue = this;
                }
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            // === Attack Method === //

            GUILayout.Label("Attack Method:", EditorStyles.boldLabel);

            Component[] components = GetAttackMethodComponents(fsm.gameObject);
            int         selectedComponent = -1, newSelectedComponent = 0;

            if (components.Length > 0)
            {
                string[] componentNames = GetAttackMethodComponentNames(components);

                for (int i = 0; i < components.Length; i++)
                {
                    if (components[i] == scriptWithAttackMethod)
                    {
                        selectedComponent = i;
                        break;
                    }
                }

                newSelectedComponent = EditorGUILayout.Popup(selectedComponent, componentNames);

                if (selectedComponent != newSelectedComponent)
                {
                    m_property = m_State.FindProperty("scriptWithAttackMethod");
                    m_property.objectReferenceValue = components[newSelectedComponent];
                }
            }
            else
            {
                AIBehaviorsCodeSampleGUI.Draw(typeof(AttackData), "attackData", "OnAttack");
            }

            if (components.Length > 0)
            {
                string[] methodNames = GetAttackMethodNamesForComponent(components[selectedComponent < 0 ? 0 : selectedComponent]);
                int      curSelectedMethod = -1, newSelectedMethod = 0;

                for (int i = 0; i < methodNames.Length; i++)
                {
                    if (methodNames[i] == methodName)
                    {
                        curSelectedMethod = i;
                        break;
                    }
                }

                newSelectedMethod = EditorGUILayout.Popup(curSelectedMethod, methodNames);

                if (curSelectedMethod != newSelectedMethod)
                {
                    m_property             = m_State.FindProperty("methodName");
                    m_property.stringValue = methodNames[newSelectedMethod];
                }
            }

            GUILayout.EndVertical();

            m_State.ApplyModifiedProperties();
        }
示例#3
0
 protected virtual void DrawAnimationFields(SerializedObject mObject)
 {
     AIBehaviorsAnimationEditorGUI.DrawAnimationFields(mObject, UsesMultipleAnimations());
     EditorGUILayout.Separator();
 }