Example #1
0
        private VisualElement GetEditorSystemDataElement()
        {
            var foldout = new Foldout
            {
                text = "Editor systems", value = false, contentContainer = { style = { marginLeft = 5 } }
            };

            if (GFEditorSystemUtility.GetSystemsData(target as Setup))
            {
                LoadLocal();
            }
            else
            {
                LoadBase();
            }

            void LoadBase()
            {
                foldout.Clear();

                foldout.Add(new Button(LoadLocal)
                {
                    text = "Add local data"
                });

                var local = GFEditorSystemUtility.GetSystemsData(target as Setup);

                if (local)
                {
                    GFEditorSystemUtility.RemoveSystemsData(target as Setup);
                    EditorFramework.IsNeedRefreshSystems = true;
                }
            }

            void LoadLocal()
            {
                foldout.Clear();
                var local = GFEditorSystemUtility.GetSystemsData(target as Setup);

                if (!local)
                {
                    local = GFEditorSystemUtility.AddSystemsData(target as Setup);
                    EditorFramework.IsNeedRefreshSystems = true;
                }


                foldout.Add(new Button(LoadBase)
                {
                    text = "Remove local data"
                });

                var element = new InspectorElement(local);

                foldout.Add(element);
            }

            return(foldout);
        }
Example #2
0
        private VisualElement GetSceneObjetsOrderElement()
        {
            var foldout = new Foldout
            {
                text = "Scene objects order", value = false, contentContainer = { style = { marginLeft = 5 } }
            };

            if (GFContextSystemUtility.GetSystemOrder(target as GFContext))
            {
                LoadLocal();
            }
            else
            {
                LoadBase();
            }

            void LoadBase()
            {
                foldout.Clear();

                foldout.Add(new Button(LoadLocal)
                {
                    text = "Add local data"
                });

                var local = GFContextSystemUtility.GetSystemOrder(target as GFContext);

                if (local)
                {
                    GFContextSystemUtility.RemoveSystemOrder(target as GFContext);
                }
            }

            void LoadLocal()
            {
                foldout.Clear();
                var local = GFContextSystemUtility.GetSystemOrder(target as GFContext);

                if (!local)
                {
                    local = GFContextSystemUtility.AddSystemOrder(target as GFContext);
                }


                foldout.Add(new Button(LoadBase)
                {
                    text = "Remove local data"
                });

                var element = new InspectorElement(local);

                foldout.Add(element);
            }

            return(foldout);
        }
Example #3
0
    private void PopulateTags(bool isOpen)
    {
        Foldout tagsFoldout = rootVisualElement.Q <Foldout>("TagsFoldout");

        tagsFoldout.SetValueWithoutNotify(isOpen);
        tagsFoldout.Clear();
        ListView listView = CreateListViewForTags();

        tagsFoldout.Add(listView);

        List <ScriptableTag> tags = ScriptableSettingsManager.Instance.Tags;

        for (int i = 0; i < tags.Count; i++)
        {
            Toggle toggle = new Toggle();
            toggle.text = " " + tags[i].name;
            int index = i;
            toggle.RegisterValueChangedCallback(x => OnToggleTag(tags[index], x));
            ContextualMenuManipulator manipulator = new ContextualMenuManipulator(x =>
            {
                x.menu.AppendAction("Delete", y => DeleteTag(tags[index]));
            })
            {
                target = toggle
            };
            listView.Add(toggle);
        }

        listView.style.height = Mathf.Min(tags.Count * 20, 100);
        Button tagsAdd = rootVisualElement.Q <Button>("TagsAdd");

        tagsAdd.clicked -= GoToCreateNewTag;
        tagsAdd.clicked += GoToCreateNewTag;
    }
        private void RefreshFoldout(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
        {
            // 清空旧元素
            foldout.Clear();

            if (collector.IsValid() == false)
            {
                Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in group : {group.GroupName}");
                return;
            }

            if (collector.CollectorType == ECollectorType.MainAssetCollector || collector.CollectorType == ECollectorType.StaticAssetCollector)
            {
                List <CollectAssetInfo> collectAssetInfos = null;

                try
                {
                    collectAssetInfos = collector.GetAllCollectAssets(group);
                }
                catch (System.Exception e)
                {
                    Debug.LogError(e.ToString());
                }

                if (collectAssetInfos != null)
                {
                    foreach (var collectAssetInfo in collectAssetInfos)
                    {
                        VisualElement elementRow = new VisualElement();
                        elementRow.style.flexDirection = FlexDirection.Row;
                        foldout.Add(elementRow);

                        string showInfo = collectAssetInfo.AssetPath;
                        if (_enableAddressableToogle.value)
                        {
                            IAddressRule    instance     = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
                            AddressRuleData ruleData     = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
                            string          addressValue = instance.GetAssetAddress(ruleData);
                            showInfo = $"[{addressValue}] {showInfo}";
                        }

                        var label = new Label();
                        label.text             = showInfo;
                        label.style.width      = 300;
                        label.style.marginLeft = 0;
                        label.style.flexGrow   = 1;
                        elementRow.Add(label);
                    }
                }
            }
        }
Example #5
0
        ///---------------------------------------------------------------------
        private void OnEnable()
        {
            // Reference to the root of the window.
            var root = rootVisualElement;

            var foldout = new Foldout()
            {
                text = "machin", viewDataKey = "foldout"
            };
            //var files = new Button() { text = "" };
            //foldout.Add(new Button() { text = "My Button" });
            //foldout.Add(new Button() { text = "My Button" });
            //foldout.Add(new Button() { text = "My Button" });

            // Creates our button and sets its Text property.
            var reloadPrateekScript = new Button()
            {
                text = "Reload"
            };

            reloadPrateekScript.clicked += () =>
            {
                prateekScriptGenerator = null;
                InitDatas();

                foldout.Clear();
                for (int w = 0; w < prateekScriptGenerator.WorkFileCount; w++)
                {
                    var label = new Label();
                    label.text = " - " + prateekScriptGenerator[w].source.name.Extension(prateekScriptGenerator[w].source.extension);
                    foldout.Add(label);
                }
            };

            //// Gives it some style.
            //myButton.style.width = 160;
            //myButton.style.height = 30;

            // Adds it to the root.
            root.Add(reloadPrateekScript);
            root.Add(foldout);
            root.Add(new Button()
            {
                text = "other"
            });
            root.Add(new TextField()
            {
                viewDataKey = "testTextField"
            });
        }
Example #6
0
 void Reload()
 {
     foldout.Clear();
     lengthField = new IntegerField("Count");
     lengthField.SetValueWithoutNotify(value.Count);
     lengthField.RegisterCallback <KeyDownEvent>(ChangeCount);
     foldout.Add(lengthField);
     for (int i = 0; i < value.Count; i++)
     {
         int j = i;
         foldout.Add(ElementExtension.DrawField("element " + j, typeof(E), value[j], _newValue =>
         {
             value[j] = (E)_newValue;
         }));
     }
 }