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);
            }
        }
Пример #2
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();
        }
Пример #4
0
        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);
        }
Пример #5
0
        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
                }
            };
        }
        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>();
        }
Пример #7
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;
        }
Пример #8
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;
        }
Пример #9
0
        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);
        }