示例#1
0
        protected virtual void CreateSearchResultSummaryControl()
        {
            TemplateContainer.Add(
                SRSummaryControl = new ASPxLabel()
                );

            SRSummaryControl.ID = Grid.GetSRSummaryControlID();
        }
示例#2
0
        public ProgressElement(Progress.Item dataSource)
        {
            rootVisualElement = new TemplateContainer();
            if (s_VisualTreeBackgroundTask == null)
            {
                s_VisualTreeBackgroundTask = EditorGUIUtility.Load(k_UxmlProgressPath) as VisualTreeAsset;
            }

            var task = new VisualElement()
            {
                name = "Task"
            };

            rootVisualElement.Add(task);
            var horizontalLayout = new VisualElement()
            {
                name = "TaskOnly"
            };

            horizontalLayout.style.flexDirection = FlexDirection.Row;
            task.Add(horizontalLayout);
            m_DetailsFoldoutToggle = new Toggle()
            {
                visible = false
            };
            m_DetailsFoldoutToggle.AddToClassList("unity-foldout__toggle");
            m_DetailsFoldoutToggle.RegisterValueChangedCallback(ToggleDetailsFoldout);
            horizontalLayout.Add(m_DetailsFoldoutToggle);
            var parentTask = s_VisualTreeBackgroundTask.CloneTree();

            parentTask.name = "ParentTask";
            horizontalLayout.Add(parentTask);

            var details = new VisualElement()
            {
                name = "Details"
            };

            details.style.display = DisplayStyle.None;
            task.Add(details);

            m_Details           = rootVisualElement.Q <VisualElement>("Details");
            m_DetailsScrollView = new ScrollView();
            m_Details.Add(m_DetailsScrollView);
            m_DetailsScrollView.AddToClassList("details-content");

            this.dataSource = dataSource;

            if (s_VisualTreeSubTask == null)
            {
                s_VisualTreeSubTask = EditorGUIUtility.Load(k_UxmlSubTaskPath) as VisualTreeAsset;
            }

            m_ProgressItemChildren = new List <Progress.Item>();
            m_SubTasks             = new List <DisplayedTask>();

            m_MainTask = InitializeTask(dataSource, rootVisualElement);
        }
示例#3
0
        /// <summary>
        /// Create a single header UI element.
        /// </summary>
        /// <param name="label">Text label for the header.</param>
        /// <param name="conditionName">Name of condition for the header, if applicable.</param>
        /// <param name="createButtons">If true, create "sync from/to" buttons for the column.</param>
        private Label CreateHeader(
            string label,
            string conditionName = defaultConditionName,
            bool createButtons   = true)
        {
            var container = new TemplateContainer();

            container.AddToClassList(columnClassName);

            var header = new Label(label);

            container.Add(header);

            if (createButtons)
            {
                var buttonContainer = new TemplateContainer();
                buttonContainer.AddToClassList(rowClassName);
                buttonContainer.AddToClassList("flex-1");
                buttonContainer.AddToClassList("justify");
                var syncFromButton = new Button(() => SyncFromLocal(conditionName))
                {
                    text    = "Set From Local",
                    tooltip = "Set values for this column from local asset values.",
                    name    = conditionName
                };
                buttonContainer.Add(syncFromButton);

                var syncToButton = new Button(() => SyncToLocal(conditionName))
                {
                    text    = "Set To Local",
                    tooltip = "Set values on local assets from this column."
                };
                buttonContainer.Add(syncToButton);
                container.Add(buttonContainer);
            }

            headerContainer.Add(container);
            return(header);
        }
            public override void OnGUI(Rect rect)
            {
                if (rendered)
                {
                    return;
                }

                if (editorWindow != null)
                {
                    editorWindow.minSize = new Vector2(300.0f, 450.0f);
                }

                VisualElement root = this.editorWindow.rootVisualElement;

                Object[] forwardStack = m_Window.GetForwardStack();
                Object[] backStack    = m_Window.GetBackStack();

                if (historyStack != null)
                {
                    root.Remove(historyStack);
                }



                var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(InspectorToolbarPackagePath + "/historyStack.uxml");

                historyStack = visualTree.CloneTree();

                var itemTemplate = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(InspectorToolbarPackagePath + "/HistoryItem.uxml");
                var styleSheet   = AssetDatabase.LoadAssetAtPath <StyleSheet>(InspectorToolbarPackagePath + "/InspectorToolbar.uss");

                root.styleSheets.Add(styleSheet);

                for (int i = forwardStack.Length - 1; i >= 0f; i--)
                {
                    CreateHistoryItem(itemTemplate, forwardStack[i], historyStack);
                }

                Label currentItem = new Label("[" + activeSelection.name + "]");

                historyStack.Add(currentItem);

                foreach (Object o in backStack)
                {
                    CreateHistoryItem(itemTemplate, o, historyStack);
                }

                root.Add(historyStack);

                rendered = true;
            }
示例#5
0
        public override VisualElement CreateInspectorGUI()
        {
            var baseUxml   = base.CreateInspectorGUI();
            var visualTree = Resources.Load("Space Extender/UXML/TranslationRedirector_Inspector") as VisualTreeAsset;

            uxml = visualTree.CloneTree();
            uxml.styleSheets.Add(Resources.Load("Space Extender/USS/BaseRedirector_Inspector_USS") as StyleSheet);

            uxml.Q("forward-gain-warning").Add(new IMGUIContainer(ShowForwardGainWarning));
            uxml.Q("backward-gain-warning").Add(new IMGUIContainer(ShowBackwardGainWarning));

            uxml.Add(baseUxml);

            return(uxml);
        }
        /// <summary>
        /// Creates the UI elements and registers callbacks.
        /// </summary>
        public void OnEnable()
        {
            syncBehaviour     = target as RemoteConfigSyncBehaviour;
            rootVisualElement = new VisualElement();
            rootVisualElement.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(stylePath));

            // Show the Script field (not-editable) like standard inspectors do.
            var script      = MonoScript.FromMonoBehaviour(syncBehaviour);
            var scriptField = new ObjectField("Script")
            {
                value = script
            };

            scriptField.SetEnabled(false);
            rootVisualElement.Add(scriptField);

            // PrefixSource enum dropdown control. When PrefixSource changes, observe whether the
            // KeyPrefix field should be shown/hidden.
            var prefixSourceProp = serializedObject.FindProperty("PrefixSource");

            prefixSourceField = new EnumField("Prefix Source", syncBehaviour.PrefixSource);
            prefixSourceField.BindProperty(prefixSourceProp);
            prefixSourceField.RegisterCallback <ChangeEvent <Enum> >(OnPrefixSourceChange);
            rootVisualElement.Add(prefixSourceField);

            // KeyPrefix control, only shown if syncBehaviour.PrefixSource == PrefixSource.Custom.
            var keyPrefixProperty = serializedObject.FindProperty("KeyPrefix");

            keyPrefixField = new PropertyField(keyPrefixProperty);
            if (syncBehaviour.PrefixSource == PrefixSource.Custom)
            {
                rootVisualElement.Add(keyPrefixField);
            }

            // Sync All Fields control.
            var syncAllProp = serializedObject.FindProperty("SyncAllFields");

            syncAllField = new PropertyField(syncAllProp);
            syncAllField.RegisterCallback <ChangeEvent <bool> >(OnSyncAllFieldsChange);
            rootVisualElement.Add(syncAllField);

            // Include sub-fields
            var includeSubProp = serializedObject.FindProperty("IncludeSubFields");

            includeSubFieldsField = new PropertyField(includeSubProp);
            if (syncBehaviour.SyncAllFields)
            {
                rootVisualElement.Add(includeSubFieldsField);
            }

            var buttonContainer = new TemplateContainer();

            // Use row class to place buttons side-by-side.
            buttonContainer.AddToClassList("row");

            // Add a button that can invoke the SyncFields function on the object during gameplay.
            var syncButton = new Button(() => SyncFields())
            {
                text = "Sync Fields"
            };

            buttonContainer.Add(syncButton);

            // Add a button that prompts RemoteConfigSyncUIWindow to update sync targets.
            var updateButton = new Button(() => SyncWindow.RefreshSyncTargets())
            {
                text = "Update targets"
            };

            buttonContainer.Add(updateButton);

            // Add button to open the RemoteConfigSyncWindow.
            var rcWindowButton = new Button(() => SyncWindow.OpenWindow())
            {
                text = "Open Sync Window"
            };

            buttonContainer.Add(rcWindowButton);
            rootVisualElement.Add(buttonContainer);
        }
示例#7
0
    private void Init()
    {
        var uiAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Scripts/USS attempt/Editor/MyWindow.uxml");

        Layout = uiAsset.CloneTree();

        var myStyle = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Scripts/USS attempt/Editor/MyStylesheet.uss");

        var myBox = new Box {
            name = "myBox"
        };

        myBox.AddToClassList("My_Fancy_box");

        input = new TextField("New Name");

        myBox.Add(input);

        var row = new VisualElement {
            name = "row"
        };

        row.Add(new Label("Position"));

        var x = new FloatField("x");
        var y = new FloatField("y");
        var z = new FloatField("z");

        x.RegisterCallback <ChangeEvent <float> >(l => pos.x = x.value);
        y.RegisterCallback <ChangeEvent <float> >(l => pos.y = y.value);
        z.RegisterCallback <ChangeEvent <float> >(l => pos.z = z.value);

        row.Add(x);
        row.Add(y);
        row.Add(z);

        myBox.Add(row);

        myBox.Q <TextField>().RegisterCallback <ChangeEvent <string> >(l => newName = (l.target as TextField).value);

        doTheThing = new Button();

        doTheThing.AddToClassList("Fancy__button");

        doTheThing.text = "Do the thing...";

        ///Button Click methods????\\\

        //doTheThing.clickable = new Clickable(delegate () { DoTheThing(); });


        //doTheThing.clickable = new Clickable(l => DoTheThing());


        //doTheThing.clickable = new Clickable(delegate () { DoTheThing(); }, 1, 1);


        //doTheThing.clickable.clicked += DoTheThing;


        //////Finally something worked
        doTheThing.clickable.clickedWithEventInfo += GoDoThatThing();


        ///Button Click methods????\\\

        myBox.Add(doTheThing);

        Layout.Add(myBox);

        rootVisualElement.styleSheets.Add(myStyle);

        rootVisualElement.Add(Layout);
    }
示例#8
0
        /// <summary>
        /// Once RemoteConfigData and SyncTargets are retrieved, render them in the ScrollView.
        /// First show unmapped parameters in a list, ending in a TextField+Button to add a new
        /// unmapped parameter.
        /// Then show all the discovered SyncTargets in hierarchy view, and highlight which ones
        /// are not synced with RemoteConfig.
        /// </summary>
        public void RenderParameters()
        {
            InitHeaders();
            var offset = valueScrollView.scrollOffset;

            valueScrollView.Clear();
            topLevelElement = new TemplateContainer();
            valueScrollView.Add(topLevelElement);

            // Render unmapped targets, if any.
            var unmappedParamsSection = new TemplateContainer();

            // Create Unmapped Parameters header section.
            var unmappedParamsHeader = new Box();

            unmappedParamsHeader.AddToClassList(headersClassName);
            var unmappedLabel = new Label("Unmapped Parameters");

            unmappedParamsHeader.Add(unmappedLabel);
            unmappedParamsSection.Add(unmappedParamsHeader);
            foreach (var param in unmappedParams.OrderBy(p => p.Key))
            {
                var unmappedTarget = new UnmappedSyncElement(param);
                unmappedParamsSection.Add(unmappedTarget);
            }

            // Add a section with TextField and Button to create a new unmapped Parameter.
            var newKeyContainer = new TemplateContainer();

            newKeyContainer.AddToClassList(columnClassName);
            newKeyContainer.AddToClassList(rowClassName);
            var newUnmappedParamText = "New Unmapped Param";
            var newKeyField          = new TextField {
                value = newUnmappedParamText
            };

            newKeyContainer.Add(newKeyField);

            var newUnmappedButton = new Button(() => {
                if (string.IsNullOrWhiteSpace(newKeyField.value))
                {
                    Debug.LogWarning("Cannot create parameter with null/whitespace key.");
                    return;
                }
                if (RemoteConfigData.parameters.ContainsKey(newKeyField.value))
                {
                    Debug.LogWarning($"A parameter with key {newKeyField.value} already exists.");
                    return;
                }
                var newParam          = RemoteConfigData.GetOrCreateParameter(newKeyField.value);
                var newUnmappedTarget = new UnmappedSyncElement(newParam);
                // Insert the new unmapped key at the end of the unmapped keys list.
                var index = unmappedParamsSection.IndexOf(newKeyContainer);
                unmappedParamsSection.Insert(index, newUnmappedTarget);
                newKeyField.value = newUnmappedParamText;
                // Apply column sizing to newly created SyncTargetElement.
                newUnmappedTarget
                .Query(null, columnClassName)
                .ForEach(col => col.style.minWidth = col.style.maxWidth = columnSize);
            });

            newUnmappedButton.text = "+";
            newUnmappedButton.AddToClassList("flex-0");
            newKeyContainer.Add(newUnmappedButton);
            unmappedParamsSection.Add(newKeyContainer);
            topLevelElement.Add(unmappedParamsSection);

            // Create a SyncGroupElement for the top-level SyncTargetContainer. SyncGroupElement and
            // the various SyncTypeElement classes handle the logic for creating the hierarchy UI.
            topLevelSyncTarget = new SyncGroupElement(SyncTargets);
            topLevelElement.Add(topLevelSyncTarget);

            // Below the ScrollView area, show a set of buttons to sync to/from RC and reset local changes.
            buttonContainer.Clear();
            buttonContainer.Add(uploadButton);
            buttonContainer.Add(downloadButton);
            buttonContainer.Add(resetChangesButton);

            // Reset UI by scrolling to previous scroll position and sizing the newly created columns.
            valueScrollView.scrollOffset = offset;
            lastTabWidth = position.width;
            ResizeColumns();
        }