private void InitializeTrees()
        {
            // We persist tree view states (most importantly, they contain our selection states),
            // so only create those if we don't have any yet.
            if (m_ActionMapsTreeState == null)
            {
                m_ActionMapsTreeState = new TreeViewState();
            }
            if (m_ActionsTreeState == null)
            {
                m_ActionsTreeState = new TreeViewState();
            }

            // Create tree in middle pane showing actions and bindings. We initially
            // leave this tree empty and populate it by selecting an action map in the
            // left pane tree.
            m_ActionsTree = new InputActionTreeView(m_ActionAssetManager.serializedObject, m_ActionsTreeState)
            {
                onSelectionChanged         = OnActionTreeSelectionChanged,
                onSerializedObjectModified = ApplyAndReloadTrees,
                drawMinusButton            = false,
                title = "Actions",
            };

            // Create tree in left pane showing action maps.
            m_ActionMapsTree = new InputActionTreeView(m_ActionAssetManager.serializedObject, m_ActionMapsTreeState)
            {
                onBuildTree = () =>
                              InputActionTreeView.BuildWithJustActionMapsFromAsset(m_ActionAssetManager.serializedObject),
                onSelectionChanged         = OnActionMapTreeSelectionChanged,
                onSerializedObjectModified = ApplyAndReloadTrees,
                onHandleAddNewAction       = m_ActionsTree.AddNewAction,
                drawMinusButton            = false,
                title = "Action Maps",
            };
            m_ActionMapsTree.Reload();
            m_ActionMapsTree.ExpandAll();

            RebuildActionTree();
            LoadPropertiesForSelection();

            // Sync current search status in toolbar.
            OnToolbarSearchChanged();
        }
Beispiel #2
0
        private void InitTreeIfNeeded(SerializedProperty property)
        {
            // NOTE: Unlike InputActionEditorWindow, we do not need to protect against the SerializedObject
            //       changing behind our backs by undo/redo here. Being a PropertyDrawer, we will automatically
            //       get recreated by Unity when it touches our serialized data.

            if (m_TreeView == null)
            {
                // Create tree and populate it.
                m_TreeView = new InputActionTreeView(property.serializedObject)
                {
                    onBuildTree   = () => BuildTree(property),
                    onDoubleClick = OnItemDoubleClicked,
                    title         = property.displayName,
                    // With the tree in the inspector, the foldouts are drawn too far to the left. I don't
                    // really know where this is coming from. This works around it by adding an arbitrary offset...
                    foldoutOffset = 14
                };
                m_TreeView.Reload();
            }
        }