void OnGUI()
        {
            if (m_SerializedObject == null)
            {
                return;
            }

            EditorGUILayout.BeginVertical();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginDisabledGroup(!m_IsAssetDirty);
            if (GUILayout.Button(EditorGUIUtility.TrTextContent("Save")))
            {
                m_IsAssetDirty = false;
                SaveChangesToAsset();
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.FlexibleSpace();
            EditorGUI.BeginChangeCheck();
            m_SearchText = m_SearchField.OnToolbarGUI(m_SearchText, GUILayout.MaxWidth(250));
            if (EditorGUI.EndChangeCheck())
            {
                m_TreeView.SetNameFilter(m_SearchText);
            }
            GUILayout.Space(5);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            DrawMainTree();
            DrawProperties();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(3);
            EditorGUILayout.EndVertical();

            if (Event.current.type == EventType.ValidateCommand)
            {
                if (m_CopyPasteUtility.IsValidCommand(Event.current.commandName))
                {
                    Event.current.Use();
                }
            }
            if (Event.current.type == EventType.ExecuteCommand)
            {
                m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName);
            }
        }
        public void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            // Toolbar.
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            EditorGUI.BeginDisabledGroup(!m_IsDirty);
            if (GUILayout.Button(m_SaveAssetGUI, EditorStyles.toolbarButton))
            {
                SaveChangesToAsset();
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginChangeCheck();
            m_SearchText = m_SearchField.OnToolbarGUI(m_SearchText, GUILayout.MaxWidth(250));
            if (EditorGUI.EndChangeCheck())
            {
                m_TreeView.SetNameFilter(m_SearchText);
            }
            GUILayout.Space(5);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            DrawMainTree();
            DrawProperties();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(3);
            EditorGUILayout.EndVertical();

            if (Event.current.type == EventType.ValidateCommand)
            {
                if (CopyPasteUtility.IsValidCommand(Event.current.commandName))
                {
                    Event.current.Use();
                }
            }
            if (Event.current.type == EventType.ExecuteCommand)
            {
                m_CopyPasteUtility.HandleCommandEvent(Event.current.commandName);
            }
        }
Example #3
0
        void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            if (m_ReferencedObject == null && !string.IsNullOrEmpty(m_AssetPath))
            {
                m_ReferencedObject = AssetDatabase.LoadAssetAtPath <InputActionAsset>(m_AssetPath);
                m_SerializedObject = null;
                m_TreeView         = null;
                return;
            }

            if (m_SerializedObject == null && m_ReferencedObject != null)
            {
                m_AssetPath        = AssetDatabase.GetAssetPath(m_ReferencedObject);
                m_SerializedObject = new SerializedObject(m_ReferencedObject);
                var pr = m_SerializedObject.FindProperty("m_ActionMaps");
                if (pr == null)
                {
                    m_ReferencedObject = null;
                    m_SerializedObject = null;
                    return;
                }
                if (m_TreeView == null)
                {
                    InitiateTrees();
                }
            }

            if (m_ReferencedObject == null)
            {
                return;
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Group filter", GUILayout.MaxWidth(70));
            m_GroupIndex = EditorGUILayout.Popup(m_GroupIndex, m_GroupPopupList.ToArray(), GUILayout.MaxWidth(200));
            if (EditorGUI.EndChangeCheck())
            {
                var filter = m_GroupIndex > 0 ? m_GroupPopupList[m_GroupIndex] : null;
                m_TreeView.SetGroupFilter(filter);
            }

            GUILayout.FlexibleSpace();
            EditorGUI.BeginChangeCheck();
            m_SearchText = m_SearchField.OnToolbarGUI(m_SearchText, GUILayout.MaxWidth(250));
            if (EditorGUI.EndChangeCheck())
            {
                m_TreeView.SetNameFilter(m_SearchText);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            DrawMainTree();
            DrawProperties();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            if (Event.current.type == EventType.ValidateCommand)
            {
                if (Event.current.commandName == "Copy" ||
                    Event.current.commandName == "Paste" ||
                    Event.current.commandName == "Cut" ||
                    Event.current.commandName == "Duplicate" ||
                    Event.current.commandName == "Delete")
                {
                    Event.current.Use();
                }
            }
            if (Event.current.type == EventType.ExecuteCommand)
            {
                switch (Event.current.commandName)
                {
                case "Copy":
                    m_CopyPasteUtility.HandleCopyEvent();
                    Event.current.Use();
                    break;

                case "Paste":
                    m_CopyPasteUtility.HandlePasteEvent();
                    Event.current.Use();
                    break;

                case "Cut":
                    m_CopyPasteUtility.HandleCopyEvent();
                    DeleteSelectedRows();
                    Event.current.Use();
                    break;

                case "Duplicate":
                    m_CopyPasteUtility.HandleCopyEvent();
                    m_CopyPasteUtility.HandlePasteEvent();
                    Event.current.Use();
                    break;

                case "Delete":
                    DeleteSelectedRows();
                    Event.current.Use();
                    break;
                }
            }
        }