Пример #1
0
 public void DoLayoutList(Action changed = null)
 {
     ScopeChange.Begin();
     if (m_serializedProperty == null)
     {
         if (isExpanded)
         {
             m_lst.DoLayoutList();
         }
         else
         {
             m_lst.DoListHeader(m_lstMethod);
         }
     }
     else
     {
         if (m_serializedProperty.isExpanded)
         {
             m_lst.DoLayoutList();
         }
         else
         {
             m_lst.DoListHeader(m_lstMethod);
         }
     }
     if (ScopeChange.End())
     {
         changed?.Invoke();
     }
 }
Пример #2
0
 public void DoLayoutList(Action changed = null)
 {
     EditorGUI.BeginChangeCheck();
     if (m_serializedProperty.isExpanded)
     {
         m_lst.DoLayoutList();
     }
     else
     {
         m_lst.DoListHeader();
     }
     if (EditorGUI.EndChangeCheck())
     {
         changed?.Invoke();
     }
 }
    public override void OnInspectorGUI()
    {
        if (state == null)
        {
            return;
        }

        if (SceneView.onSceneGUIDelegate != this.OnSceneView && state is AISystem.States.NavMeshAgent.Patrol)
        {
            SceneView.onSceneGUIDelegate += this.OnSceneView;
        }

        if (stateFields.Length > 0)
        {
            if (stateList.DoListHeader())
            {
                GUILayout.BeginVertical(GUIContent.none, "PopupCurveSwatchBackground");
                GUILayout.Space(2);
                SerializedObject obj = new SerializedObject(state);
                obj.Update();
                for (int cnt = 0; cnt < stateFields.Length; cnt++)
                {
                    bool hasChildren = obj.FindProperty(stateFields [cnt].Name).CountInProperty() > 1;
                    if (hasChildren)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(15f);
                        GUILayout.BeginVertical();
                    }
                    EditorGUILayout.PropertyField(obj.FindProperty(stateFields [cnt].Name), true);
                    if (hasChildren)
                    {
                        GUILayout.EndVertical();
                        GUILayout.EndHorizontal();
                    }
                }
                obj.ApplyModifiedProperties();
                GUILayout.EndVertical();
            }

            GUILayout.Space(10f);
        }

        if (actionList != null)
        {
            actionList.DoList();
            GUILayout.Space(10f);
        }

        if (state.transitions.Count > 0)
        {
            transitionList.DoList();
            GUILayout.Space(10f);
            if (transitionIndexChanged && Event.current.type == EventType.Layout)
            {
                conditionList          = null;
                transitionIndexChanged = false;
            }
            if (conditionList == null)
            {
                conditionList = new ReorderableList(state.transitions[transitionIndex].conditions, "Conditions", true, true, true);
                conditionList.onAddCallback       = AddCondition;
                conditionList.onRemoveCallback    = RemoveCondition;
                conditionList.drawElementCallback = DrawConditionElement;
                conditionList.onHeaderClick       = OnConditionHeaderClick;
            }
            conditionList.DoList();
        }
    }