void InitTreeIfNeeded(SerializedProperty property)
 {
     if (m_TreeView == null)
     {
         m_TreeView = InputActionComponentListTreeView.CreateFromActionProperty(() => {}, property);
         m_TreeView.OnContextClick = OnContextClick;
     }
 }
Esempio n. 2
0
 private void InitTreeIfNeeded(SerializedProperty property)
 {
     if (m_TreeView == null)
     {
         m_TreeView = CreateTree(property);
         m_TreeView.OnContextClick = OnContextClick;
         m_CopyPasteUtility        = new CopyPasteUtility(m_TreeView);
     }
 }
 void OnUndoRedoCallback()
 {
     if (m_TreeView == null)
     {
         //TODO how to unregister it in a better way?
         Undo.undoRedoPerformed -= OnUndoRedoCallback;
         return;
     }
     // Force tree rebuild
     m_TreeView = null;
 }
        public static InputActionListTreeView CreateFromSerializedObject(Action applyAction, SerializedObject serializedObject, ref TreeViewState treeViewState)
        {
            if (treeViewState == null)
                treeViewState = new TreeViewState();

            var treeView = new InputActionListTreeView(applyAction, treeViewState);
            treeView.m_SerializedObject = serializedObject;
            treeView.Reload();
            treeView.ExpandAll();
            return treeView;
        }
Esempio n. 5
0
 void InitiateTrees()
 {
     if (m_SerializedObject != null)
     {
         m_SearchField = new SearchField();
         m_TreeView    = InputActionListTreeView.Create(Apply, m_ReferencedObject as InputActionAsset, m_SerializedObject, ref m_TreeViewState);
         m_TreeView.OnSelectionChanged = OnSelectionChanged;
         m_TreeView.OnContextClick     = OnContextClick;
         m_CopyPasteUtility            = new CopyPasteUtility(this, m_TreeView, m_SerializedObject);
         LoadPropertiesForSelection();
     }
 }
        public static InputActionListTreeView Create(Action applyAction, InputActionAsset asset, SerializedObject serializedObject, ref TreeViewState treeViewState)
        {
            if (treeViewState == null)
            {
                treeViewState = new TreeViewState();
            }

            var treeView = new InputActionListTreeView(applyAction, asset, serializedObject, treeViewState);

            ////FIXME: this requires 2018.3 to compile
            //treeView.foldoutOverride += OnFoldoutDraw;
            treeView.ExpandAll();
            return(treeView);
        }
 void InitializeTrees()
 {
     if (m_SerializedObject != null)
     {
         m_SearchField = new SearchField();
         m_TreeView    = InputActionListTreeView.CreateFromSerializedObject(Apply, m_SerializedObject, ref m_TreeViewState);
         m_TreeView.OnSelectionChanged = OnSelectionChanged;
         m_TreeView.OnContextClick     = OnContextClick;
         m_CopyPasteUtility            = new CopyPasteUtility(Apply, m_TreeView, m_SerializedObject);
         if (m_PickerTreeViewState == null)
         {
             m_PickerTreeViewState = new TreeViewState();
         }
         LoadPropertiesForSelection();
     }
 }
Esempio n. 8
0
 public CopyPasteUtility(ActionInspectorWindow window)
 {
     m_Window   = window;
     m_TreeView = window.m_TreeView;
 }
Esempio n. 9
0
 public CopyPasteUtility(ActionInspectorWindow window, InputActionListTreeView tree, SerializedObject serializedObject)
 {
     m_Window           = window;
     m_TreeView         = tree;
     m_SerializedObject = serializedObject;
 }
Esempio n. 10
0
 public CopyPasteUtility(InputActionListTreeView treeView)
 {
     m_TreeView = treeView;
     m_Apply    = () => { m_TreeView.Reload(); };
 }
Esempio n. 11
0
 public CopyPasteUtility(Action apply, InputActionListTreeView tree, SerializedObject serializedObject)
 {
     m_Apply            = apply;
     m_TreeView         = tree;
     m_SerializedObject = serializedObject;
 }
Esempio n. 12
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;
                }
            }
        }