Beispiel #1
0
            /// <summary> Draws the left column from the avaliable types. </summary>
            private void DrawLeftColumnItems()
            {
                // Clears out old visual elements.
                leftColumnItems.Clear();
                DataManagerDataTypeFinder.CheckForNewDataTypes();

                #region Sets up ListView.
                visibleEntries = new List <DataManagerSettingsEntry>();
                foreach (DataManagerSettingsEntry entry in DataManagerSettingsAccessor.Settings.EntriesArray)
                {
                    if (entry.visiblity == VisiblityToManager.Visible)
                    {
                        visibleEntries.Add(entry);
                    }
                }

                Func <VisualElement> makeItem = () => new Label();

                Action <VisualElement, int> bindItem = (e, i) => (e as Label).text = visibleEntries.ToArray()[i].typeAsString;
                bindItem += (e, i) => (e as Label).AddToClassList("item_list"); // Adds the class but does not use styling for some reason.

                const int itemHeight = 20;

                leftList = new ListView(visibleEntries, itemHeight, makeItem, bindItem);
                leftList.AddToClassList("list");
                leftList.selectionType       = SelectionType.Single;
                leftList.onSelectionChanged += CheckForSelectedType;

                leftColumnItems.Add(leftList);
                #endregion
            }
Beispiel #2
0
            //[SettingsProvider]
            public static SettingsProvider CreateDataManagerSettings()
            {
                DataManagerDataTypeFinder.CheckForNewDataTypes();

                currentTarget = null;

                SettingsProvider provider = new SettingsProvider("ACTools/Data Manager", SettingsScope.User)
                {
                    activateHandler = (searchContext, rootElement) =>
                    {
                        SerializedObject serializedSettings = DataManagerSettingsAccessor.GetSerializedSettings();

                        #region UXML and USS set-up
                        // Import UXML and USS
                        VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/_ACTools/_Data Manager/Editor/DataManagerSettingsProvider.uxml");
                        StyleSheet      styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/_ACTools/_Data Manager/Editor/DataManagerSettingsProvider.uss");

                        // Adds style sheet to root.
                        rootElement.styleSheets.Add(styleSheet);

                        // Clones the visual tree and adds it to the root.
                        VisualElement tree = visualTree.CloneTree();
                        rootElement.Add(tree);
                        #endregion

                        #region Sets up button.
                        if (button == null)
                        {
                            button = (Button)tree.hierarchy.ElementAt(1);
                        }
                        button.SetEnabled(false);
                        button.clickable.clicked += SwitchTargetEnabledStatus;
                        #endregion

                        #region Sets up ListView.
                        Func <VisualElement> makeItem = () => new Label();

                        Action <VisualElement, int> bindItem = (e, i) => (e as Label).text = DataManagerSettingsAccessor.Settings.EntriesArray[i].typeAsString;

                        const int itemHeight = 16;

                        listView = new ListView(DataManagerSettingsAccessor.Settings.EntriesArray, itemHeight, makeItem, bindItem);
                        listView.AddToClassList("list");
                        listView.selectionType       = SelectionType.Single;
                        listView.onSelectionChanged += UpdateButton;

                        rootElement.Add(listView);
                        #endregion
                    },

                    // Populate the search keywords to enable smart search filtering and label highlighting.
                    keywords = new HashSet <string>(new[] { "ACTools", "Data", "Manager", "Data Manager" })
                };

                return(provider);
            }
Beispiel #3
0
            /// <summary> Called when the refreshDataManagerButton is pressed. </summary>
            private void RefreshDataManagerAction()
            {
                DataTypeSelected = false;
                ItemSelected     = false;

                DataManagerDataTypeFinder.CheckForNewDataTypes();

                DrawLeftColumnItems();
                DrawRightColumnItems();
            }