public BuilderCanvasStyleControls()
        {
            this.AddToClassList("unity-builder-canvas-style-controls");

            // Load Template
            var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Viewport/BuilderCanvasStyleControls.uxml");

            template.CloneTree(this);

            // Load Styles
            var uss = BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(
                BuilderConstants.UIBuilderPackagePath + "/Viewport/BuilderCanvasStyleControls.uss");

            this.styleSheets.Add(uss);

            // Fetch buttons.
            m_FlexDirectionButton       = QueryAndBindButton("flex-direction-button", FlexDirectionOnToggle);
            m_AlignItemsButton          = QueryAndBindButton("align-items-button", AlignItemsOnToggle);
            m_JustifyContentButton      = QueryAndBindButton("justify-content-button", JustifyContentOnToggle);
            m_HorizontalTextAlignButton = QueryAndBindButton("horizontal-text-align-button", HorizontalTextAlignOnToggle);
            m_VerticalTextAlignButton   = QueryAndBindButton("vertical-text-align-button", VerticalTextAlignOnToggle);
            m_TextWrapButton            = QueryAndBindButton("text-wrap-button", TextWrapOnToggle);

            // Group special buttons.
            m_FlexAlignButtons.Add(m_FlexDirectionButton);
            m_FlexAlignButtons.Add(m_AlignItemsButton);
            m_FlexAlignButtons.Add(m_JustifyContentButton);
        }
        public RotateStyleField(string label) : base(label)
        {
            AddToClassList(BuilderConstants.InspectorContainerClassName);
            AddToClassList(s_FieldClassName);

            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssPath));

            var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(s_UxmlPath);

            template.CloneTree(this);

            visualInput = this.Q(s_VisualInputName);

            m_RotateXField = this.Q <AngleStyleField>(s_RotateXFieldName);

            m_RotateXField.RegisterValueChangedCallback(e =>
            {
                UpdateRotateField();
                e.StopPropagation();
            });

            value = new BuilderRotate()
            {
                x = new Dimension {
                    value = 0, unit = Dimension.Unit.Degree
                }
            };
        }
Beispiel #3
0
        static void GetAllReferencedStyleSheets(VisualElementAsset vea, HashSet <StyleSheet> sheets)
        {
            var styleSheets = vea.stylesheets;

            if (styleSheets != null)
            {
                foreach (var styleSheet in styleSheets)
                {
                    if (styleSheet != null) // Possible if the path is not valid.
                    {
                        sheets.Add(styleSheet);
                    }
                }
            }

            var styleSheetPaths = vea.GetStyleSheetPaths();

            if (styleSheetPaths != null)
            {
                foreach (var sheetPath in styleSheetPaths)
                {
                    var sheetAsset = BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(sheetPath);
                    if (sheetAsset == null)
                    {
                        sheetAsset = Resources.Load <StyleSheet>(sheetPath);
                        if (sheetAsset == null)
                        {
                            continue;
                        }
                    }

                    sheets.Add(sheetAsset);
                }
            }
        }
        public StyleField(string label) : base(label)
        {
            AddToClassList(s_UssClassName);

            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssPath));

            var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(s_UxmlPath);

            template.CloneTree(this);

            visualInput           = this.Q(s_VisualInputName);
            m_TextField           = this.Q <TextField>(s_TextFieldName);
            m_TextField.isDelayed = true;

            var popupContainer = this.Q(s_OptionsPopupContainerName);

            m_StyleKeywords            = StyleFieldConstants.KLDefault;
            m_CachedRegularOptionsList = GenerateAdditionalOptions(string.Empty);
            m_AllOptionsList           = new List <string>();
            m_AllOptionsList.AddRange(m_CachedRegularOptionsList);
            m_AllOptionsList.AddRange(m_StyleKeywords);
            m_OptionsPopup = new PopupField <string>(m_AllOptionsList, 0, OnFormatSelectedValue);
            m_OptionsPopup.AddToClassList(s_OptionsPopupUssClassName);
            popupContainer.Add(m_OptionsPopup);

            m_TextField.RegisterValueChangedCallback(OnTextFieldValueChange);
            m_OptionsPopup.RegisterValueChangedCallback(OnPopupFieldValueChange);
        }
        public BuilderAttributeTypeName()
        {
            AddToClassList(s_BaseClass);

            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssPath));
            if (EditorGUIUtility.isProSkin)
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssDarkPath));
            }
            else
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssLightPath));
            }

            m_Namespace = new VisualElement();
            m_Namespace.AddToClassList(s_NamespaceContainerClass);
            m_TypeName = new VisualElement();
            m_TypeName.AddToClassList(s_TypeNameContainerClass);

            Add(m_TypeName);
            Add(m_Namespace);

            // Trailing spaces are trimmed when measuring the text, so we'll add a class on this particular Label to
            // force some padding on the right.
            m_InNamespace = new Label("in");
            m_InNamespace.AddToClassList(s_NamespacePrefixClass);
        }
Beispiel #6
0
        public ScaleStyleField(string label) : base(label)
        {
            AddToClassList(BuilderConstants.InspectorContainerClassName);
            AddToClassList(s_FieldClassName);

            var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(s_UxmlPath);

            template.CloneTree(this);

            visualInput = this.Q(s_VisualInputName);

            m_ScaleXField = this.Q <DimensionStyleField>(s_ScaleXFieldName);
            m_ScaleYField = this.Q <DimensionStyleField>(s_ScaleYFieldName);

            m_ScaleXField.RegisterValueChangedCallback(e =>
            {
                UpdateScaleField();
                e.StopPropagation();
            });
            m_ScaleYField.RegisterValueChangedCallback(e =>
            {
                UpdateScaleField();
                e.StopPropagation();
            });

            value = new BuilderScale()
            {
                value = Vector3.zero
            };
        }
        bool PostSaveToDiskChecksAndFixes(string newUxmlPath, bool needsFullRefresh)
        {
            var oldVTAReference = m_VisualTreeAsset;
            var oldUxmlPath     = uxmlPath;
            var hasNewUxmlPath  = !string.IsNullOrEmpty(newUxmlPath) && newUxmlPath != oldUxmlPath;
            var localUxmlPath   = !string.IsNullOrEmpty(newUxmlPath) ? newUxmlPath : oldUxmlPath;

            m_VisualTreeAsset = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(localUxmlPath);
            var newIsDifferentFromOld = m_VisualTreeAsset != oldVTAReference;

            // If we have a new uxmlPath, it means we're saving as and we need to reset the
            // original document to stock.
            if (hasNewUxmlPath && newIsDifferentFromOld && !string.IsNullOrEmpty(oldUxmlPath))
            {
                m_DocumentBeingSavedExplicitly = true;
                AssetDatabase.ImportAsset(oldUxmlPath, ImportAssetOptions.ForceUpdate);
                m_DocumentBeingSavedExplicitly = false;
            }

            needsFullRefresh |= newIsDifferentFromOld;

            // Check if the UXML asset has changed and reload it.
            if (needsFullRefresh)
            {
                // To get all the selection markers into the new assets.
                m_VisualTreeAssetBackup.DeepOverwrite(m_VisualTreeAsset);
                m_VisualTreeAsset.ConvertAllAssetReferencesToPaths();
            }
            return(needsFullRefresh);
        }
Beispiel #8
0
        public BuilderAnchorer()
        {
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Manipulators/BuilderAnchorer.uxml");

            builderTemplate.CloneTree(this);

            AddToClassList(s_UssClassName);

            m_HandleElements = new Dictionary <string, VisualElement>();

            m_HandleElements.Add("top-anchor", this.Q("top-anchor"));
            m_HandleElements.Add("left-anchor", this.Q("left-anchor"));
            m_HandleElements.Add("bottom-anchor", this.Q("bottom-anchor"));
            m_HandleElements.Add("right-anchor", this.Q("right-anchor"));

            m_HandleElements["top-anchor"].AddManipulator(new Clickable(OnAnchorClickTop));
            m_HandleElements["left-anchor"].AddManipulator(new Clickable(OnAnchorClickLeft));
            m_HandleElements["bottom-anchor"].AddManipulator(new Clickable(OnAnchorClickBottom));
            m_HandleElements["right-anchor"].AddManipulator(new Clickable(OnAnchorClickRight));

            m_AbsoluteOnlyHandleElements.Add(m_HandleElements["top-anchor"]);
            m_AbsoluteOnlyHandleElements.Add(m_HandleElements["left-anchor"]);
            m_AbsoluteOnlyHandleElements.Add(m_HandleElements["bottom-anchor"]);
            m_AbsoluteOnlyHandleElements.Add(m_HandleElements["right-anchor"]);
        }
        public void OnEnable()
        {
            var root = rootVisualElement;

            // Load styles.
            root.styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(
                                     BuilderConstants.UtilitiesPath + "/UIExtensionsTestWindow/UIExtensionsTestWindow.uss"));

            // Load template.
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UtilitiesPath + "/UIExtensionsTestWindow/UIExtensionsTestWindow.uxml");

            builderTemplate.CloneTree(root);

            // Init fields.
            m_StyleSheetField            = root.Q <ObjectField>("uss-object-field");
            m_StyleSheetField.objectType = typeof(StyleSheet);
            m_StyleSheetField.RegisterValueChangedCallback(StyleSheetChanged);
            m_StyleSheetContents              = root.Q("uss-contents");
            m_VisualTreeAssetField            = root.Q <ObjectField>("uxml-object-field");
            m_VisualTreeAssetField.objectType = typeof(VisualTreeAsset);
            m_VisualTreeAssetContents         = root.Q("uxml-contents");
            m_VisualTreeAssetField.RegisterValueChangedCallback(VisualTreeAssetChanged);

            // Get container;
            m_Container = root.Q("container");

            AssetDatabase.ImportAsset(s_DefaultUSSPath, ImportAssetOptions.ForceUpdate);
            AssetDatabase.ImportAsset(s_DefaultUXMLPath, ImportAssetOptions.ForceUpdate);

            root.schedule.Execute(AfterImport);
        }
Beispiel #10
0
        protected virtual void OnEnable()
        {
            var root = rootVisualElement;

            // Load assets.
            var mainSS  = BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UIBuilderPackagePath + "/Builder.uss");
            var themeSS = EditorGUIUtility.isProSkin
                ? BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UIBuilderPackagePath + "/BuilderDark.uss")
                : BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UIBuilderPackagePath + "/BuilderLight.uss");

            // HACK: Check for null assets.
            // See: https://fogbugz.unity3d.com/f/cases/1180330/
            if (mainSS == null || themeSS == null)
            {
                EditorApplication.delayCall += () =>
                {
                    this.m_Parent.Reload(this);
                };
                return;
            }

            // Load styles.
            root.styleSheets.Add(mainSS);
            root.styleSheets.Add(themeSS);

            // Handle viewport window.
            if (this is IBuilderViewportWindow || document.primaryViewportWindow != null)
            {
                CreateUIInternal();
            }

            // Register window.
            document.RegisterWindow(this);
        }
Beispiel #11
0
        public ModalPopup()
        {
            AddToClassList(s_UssClassName);
            AddToClassList(s_InvisibleClassName);

            // Load styles.
            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/ModalPopup/ModalPopup.uss"));
            if (EditorGUIUtility.isProSkin)
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/ModalPopup/ModalPopupDark.uss"));
            }
            else
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/ModalPopup/ModalPopupLight.uss"));
            }

            var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.UtilitiesPath + "/ModalPopup/ModalPopup.uxml");

            template.CloneTree(this);

            m_Title     = this.Q <Label>("title");
            m_Container = this.Q("content-container");

            var window = this.Q("window");

            window.RegisterCallback <MouseUpEvent>(StopPropagation);

            this.RegisterCallback <MouseUpEvent>(HideOnClick);
        }
        public void OnEnable()
        {
            var root = rootVisualElement;

            // Load styles.
            root.styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath<StyleSheet>(BuilderConstants.UIBuilderPackagePath + "/Builder.uss"));
            if (EditorGUIUtility.isProSkin)
                root.styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath<StyleSheet>(BuilderConstants.UIBuilderPackagePath + "/BuilderDark.uss"));
            else
                root.styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath<StyleSheet>(BuilderConstants.UIBuilderPackagePath + "/BuilderLight.uss"));

            // Load template.
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath<VisualTreeAsset>(BuilderConstants.UIBuilderPackagePath + "/BuilderPreviewWindow.uxml");
            builderTemplate.CloneTree(root);

            // Init field.
            m_UxmlAssetField = root.Q<ObjectField>();
            m_UxmlAssetField.objectType = typeof(VisualTreeAsset);
            m_UxmlAssetField.RegisterValueChangedCallback(VisualTreeAssetChanged);
            m_Container = root.Q("container");

            // Clone tree if we have an asset loaded.
            m_UxmlAssetField.value = m_CurrentVisualTreeAsset;
            CloneTree();
        }
        public FoldoutWithCheckbox()
        {
            m_Toggle.text           = string.Empty;
            m_Toggle.style.flexGrow = 0;

            m_Checkbox = new Toggle();
            m_Checkbox.style.flexGrow = 0;

            m_Checkbox.AddToClassList(k_CheckboxClassName);
            m_Checkbox.RegisterValueChangedCallback(e
                                                    => SetCheckboxValueWithoutNotify(e.newValue));
            m_Header.hierarchy.Add(m_Checkbox);

            m_Label = new Label();
            m_Label.AddToClassList(k_LabelClassName);
            m_Label.AddManipulator(new Clickable(evt =>
            {
                if ((evt as MouseUpEvent)?.button == (int)MouseButton.LeftMouse)
                {
                    m_Toggle.value = !m_Toggle.value;
                }
            }));

            m_Header.hierarchy.Add(m_Label);

            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(k_UssPath));
        }
        public BuilderLibraryTreeView(IList <ITreeViewItem> items)
        {
            m_TreeViewItemTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.LibraryUIPath + "/BuilderLibraryTreeViewItem.uxml");

            style.flexGrow = 1;
            m_TreeView     = new TreeView {
                name = k_TreeViewName
            };
            m_TreeView.AddToClassList(k_TreeViewClassName);
            Add(m_TreeView);

            m_TreeView.viewDataKey = "samples-tree";
            m_TreeView.itemHeight  = 20;
            m_TreeView.rootItems   = items;
            m_TreeView.makeItem    = MakeItem;
            m_TreeView.bindItem    = BindItem;
#if UNITY_2019_4
            m_TreeView.onItemChosen += (s) => OnItemChosen(s);
#else
            m_TreeView.onItemsChosen += OnItemsChosen;
#endif
            m_TreeView.Refresh();

            foreach (var item in m_TreeView.rootItems)
            {
                m_TreeView.ExpandItem(item.id);
            }
        }
        void SetUpFileMenu()
        {
            m_FileMenu.menu.AppendAction("New", a =>
            {
                NewDocument();
            });

            if (Unsupported.IsDeveloperMode())
            {
                m_FileMenu.menu.AppendAction("New (Test)", a =>
                {
                    NewTestDocument();
                });

                m_FileMenu.menu.AppendAction("New (Test Variables)", a =>
                {
                    NewTestVariablesDocument();
                });
            }

            m_FileMenu.menu.AppendAction("Open...", a =>
            {
                var path = OpenLoadFileDialog(BuilderConstants.ToolbarLoadUxmlDialogTitle, BuilderConstants.Uxml);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                var appPath = Application.dataPath;
                if (path.StartsWith(appPath))
                {
                    path = "Assets/" + path.Substring(appPath.Length);
                }
                else
                {
                    Debug.LogError(BuilderConstants.ToolbarCannotLoadUxmlOutsideProjectMessage);
                    return;
                }

                var asset = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(path);
                if (asset == null)
                {
                    Debug.LogError(BuilderConstants.ToolbarSelectedAssetIsInvalidMessage);
                    return;
                }

                LoadDocument(asset);
            });

            m_FileMenu.menu.AppendSeparator();

            m_FileMenu.menu.AppendAction("Save", a =>
            {
                SaveDocument(false);
            });
            m_FileMenu.menu.AppendAction("Save As...", a =>
            {
                SaveDocument(true);
            });
        }
Beispiel #16
0
 public LibraryFoldout()
 {
     // Load styles.
     styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/LibraryFoldout/LibraryFoldout.uss"));
     styleSheets.Add(EditorGUIUtility.isProSkin
         ? BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/LibraryFoldout/LibraryFoldoutDark.uss")
         : BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/LibraryFoldout/LibraryFoldoutLight.uss"));
 }
        public BuilderPlacementIndicator()
        {
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Manipulators/BuilderPlacementIndicator.uxml");

            builderTemplate.CloneTree(this);

            AddToClassList(s_UssClassName);
        }
Beispiel #18
0
        protected override VisualElement CreateDraggedElement()
        {
            var classPillTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/BuilderClassPill.uxml");
            var pill = classPillTemplate.CloneTree();

            pill.AddToClassList(s_DraggableStyleClassPillClassName);
            return(pill);
        }
Beispiel #19
0
        public static void ConvertAllAssetReferencesToPaths(this VisualTreeAsset vta)
        {
            var sheets = new HashSet<StyleSheet>();
            foreach (var asset in vta.visualElementAssets)
            {
                sheets.Clear();

                foreach (var styleSheet in asset.stylesheets)
                    sheets.Add(styleSheet);

                foreach (var sheetPath in asset.stylesheetPaths)
                {
                    var sheetAsset = BuilderPackageUtilities.LoadAssetAtPath<StyleSheet>(sheetPath);
                    if (sheetAsset == null)
                    {
                        sheetAsset = Resources.Load<StyleSheet>(sheetPath);
                        if (sheetAsset == null)
                            continue;
                    }

                    sheets.Add(sheetAsset);
                }

                asset.stylesheetPaths.Clear();
                foreach (var sheet in sheets)
                {
                    var path = AssetDatabase.GetAssetPath(sheet);
                    if (string.IsNullOrEmpty(path))
                        continue;

                    asset.stylesheetPaths.Add(path);
                }
            }

            var fieldInfo = UsingsListFieldInfo;
            if (fieldInfo != null)
            {
                var usings = fieldInfo.GetValue(vta) as List<VisualTreeAsset.UsingEntry>;
                if (usings != null && usings.Count > 0)
                {
                    for (int i = 0; i < usings.Count; ++i)
                    {
                        if (usings[i].asset == null)
                            continue;

                        var u = usings[i];
                        u.path = AssetDatabase.GetAssetPath(u.asset);
                        usings[i] = u;
                    }
                }
            }
            else
            {
                Debug.LogError("UI Builder: VisualTreeAsset.m_Usings field has not been found! Update the reflection code!");
            }
        }
        void OnEnable()
        {
            var root = rootVisualElement;

            root.styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.UtilitiesPath + "/TwoPaneSplitViewTestWindow/TwoPaneSplitViewTestWindow.uss"));

            var xmlAsset = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.UtilitiesPath + "/TwoPaneSplitViewTestWindow/TwoPaneSplitViewTestWindow.uxml");

            xmlAsset.CloneTree(root);
        }
        public BuilderStyleRow()
        {
            AddToClassList(s_UssClassName);

            var visualAsset = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Inspector/BuilderStyleRow.uxml");

            visualAsset.CloneTree(this);

            m_Container = this.Q("content-container");
        }
Beispiel #22
0
        protected TransformOriginSelectorPointBase(string visualContentUXMLFile = null)
        {
            AddToClassList(s_UssClassName);
            style.position = Position.Absolute;
            var           template      = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(visualContentUXMLFile);
            VisualElement visualContent = template.Instantiate();

            visualContent.pickingMode = PickingMode.Ignore;

            Add(visualContent);
            visualContent.name = s_VisualContentName;
        }
Beispiel #23
0
        public BuilderExplorer(
            BuilderPaneWindow paneWindow,
            BuilderViewport viewport,
            BuilderSelection selection,
            BuilderClassDragger classDragger,
            BuilderExplorerDragger explorerDragger,
            BuilderElementContextMenu contextMenuManipulator,
            VisualElement documentElementRoot,
            bool includeDocumentElementRoot,
            HighlightOverlayPainter highlightOverlayPainter,
            string toolbarUxmlPath)
        {
            m_PaneWindow                 = paneWindow;
            m_Viewport                   = viewport;
            m_DocumentElementRoot        = documentElementRoot;
            m_IncludeDocumentElementRoot = includeDocumentElementRoot;
            m_DocumentElement            = viewport.documentRootElement;
            AddToClassList(s_UssClassName);

            m_ClassDragger    = classDragger;
            m_ExplorerDragger = explorerDragger;

            m_SelectionMadeExternally = false;

            m_Selection = selection;

            // Query the UI
            if (!string.IsNullOrEmpty(toolbarUxmlPath))
            {
                var template = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(toolbarUxmlPath);
                template.CloneTree(this);
            }

            // Create the Hierarchy View.
            m_ElementHierarchyView = new ElementHierarchyView(
                m_PaneWindow,
                m_DocumentElement,
                selection, classDragger, explorerDragger,
                contextMenuManipulator, ElementSelectionChanged, highlightOverlayPainter);
            m_ElementHierarchyView.style.flexGrow = 1;
            Add(m_ElementHierarchyView);

            // Enable horizontal scrolling.
#if UNITY_2020_2_OR_NEWER
            m_ElementHierarchyView.Q <TreeView>().horizontalScrollingEnabled = true;
#endif

            // Make sure the Hierarchy View gets focus when the pane gets focused.
            primaryFocusable = m_ElementHierarchyView.Q <ListView>();

            UpdateHierarchyAndSelection(false);
            m_ShouldRebuildHierarchyOnStyleChange = true;
        }
        public BuilderSelectionIndicator()
        {
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Manipulators/BuilderSelectionIndicator.uxml");

            builderTemplate.CloneTree(this);

            AddToClassList(s_UssClassName);
            m_Header              = this.Q("header");
            m_HeaderLabel         = m_Header.Q <Label>("header-label");
            m_CanvasStyleControls = m_Header.Q <BuilderCanvasStyleControls>();
        }
        public BuilderLibraryPlainView(IEnumerable <ITreeViewItem> items)
        {
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.LibraryUIPath + "/BuilderLibraryPlainView.uxml");

            builderTemplate.CloneTree(this);

            m_Items                      = items;
            m_ContentContainer           = this.Q <VisualElement>(k_ContentContainerName);
            m_ContentContainer.focusable = true;
            m_ContentContainer.RegisterCallback <FocusEvent>(OnFocusEvent);
            m_ContentContainer.RegisterCallback <BlurEvent>(OnBlurEvent);
        }
        public ToggleButtonStrip(string label, IList <string> choices) : base(label)
        {
            AddToClassList(s_UssClassName);

            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssPath));

            m_ButtonStrip = new ButtonStrip();
            m_ButtonStrip.onButtonClick = OnOptionChange;
            visualInput = m_ButtonStrip;

            this.choices = choices;
        }
Beispiel #27
0
        public FontStyleStrip(string label) : base(label)
        {
            AddToClassList(s_UssClassName);

            styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(s_UssPath));

            m_ButtonStrip = new ButtonStrip();
            m_ButtonStrip.onButtonClick = OnOptionChange;
            visualInput = m_ButtonStrip;

            m_ButtonStrip.choices = s_VisibleChoices;
        }
Beispiel #28
0
        public BuilderTransformer()
        {
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(
                BuilderConstants.UIBuilderPackagePath + "/Manipulators/BuilderTransformer.uxml");

            builderTemplate.CloneTree(this);

            AddToClassList(s_UssClassName);

            m_ScratchChangeList = new List <string>();

            m_DragHoverCoverLayer = this.Q("drag-hover-cover-layer");
        }
        public TransitionsListView()
        {
            var styleSheet = BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(k_UssPath);

            styleSheets.Add(styleSheet);

            if (EditorGUIUtility.isProSkin)
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(k_UssDarkSkinPath));
            }
            else
            {
                styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(k_UssLightSkinPath));
            }

            AddToClassList(k_BaseClass);

            var content = new VisualElement();

            contentContainer = content;
            content.AddToClassList(k_ContentClass);

            hierarchy.Add(content);

            m_AddTransitionButton = new Button(OnTransitionAdded);
            var addButtonIcon = new VisualElement();

            addButtonIcon.AddToClassList(k_AddButtonIconClass);
            m_AddTransitionButton.Add(addButtonIcon);
            var buttonLabel = new Label(k_AddButtonText);

            buttonLabel.AddToClassList(k_AddButtonLabelClass);
            m_AddTransitionButton.Add(buttonLabel);
            m_AddTransitionButton.AddToClassList(k_AddButtonClass);
            hierarchy.Add(m_AddTransitionButton);

            m_TransitionNotVisibleWarning = new HelpBox
            {
                text = BuilderConstants.TransitionWillNotBeVisibleBecauseOfDuration
            };
            m_TransitionNotVisibleWarning.AddToClassList(k_NoDurationWarningClass);
            hierarchy.Add(m_TransitionNotVisibleWarning);

            m_EditPropertyToAddNewTransitionWarning = new HelpBox
            {
                text = BuilderConstants.EditPropertyToAddNewTransition
            };
            m_EditPropertyToAddNewTransitionWarning.AddToClassList(k_EditPropertyToAddWarningClass);
            hierarchy.Add(m_EditPropertyToAddNewTransitionWarning);
        }
        void NewTestVariablesDocument()
        {
            if (!document.CheckForUnsavedChanges())
            {
                return;
            }

            var testAsset =
                BuilderConstants.UIBuilderPackagePath +
                "/SampleDocument/BuilderVariableSampleCanvas.uxml";
            var originalAsset = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(testAsset);

            LoadDocument(originalAsset);
        }