protected override void BuildUI()
        {
            var selectionBorder = new VisualElement();

            selectionBorder.AddToClassList("ge-node__selection-border");
            Add(selectionBorder);

            var contentContainerElement = new VisualElement();

            contentContainerElement.AddToClassList("ge-node__content-container");
            selectionBorder.Add(contentContainerElement);
            m_ContentContainer = contentContainerElement;

            base.BuildUI();

            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "PropertyField.uss"));
            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Node.uss"));
            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Token.uss"));

            if (TitleLabel != null)
            {
                if (Model is IObjectReference modelReference)
                {
                    if (modelReference is IExposeTitleProperty titleProperty)
                    {
                        TitleLabel.BindingPath = titleProperty.TitlePropertyName;
                    }
                }
            }

            if (Model is ConstantNodeModel constantNodeModel)
            {
                SetupConstantEditor(constantNodeModel);
                AddToClassList(k_UssClassName + "--constant-token");
            }
            else if (Model is VariableNodeModel && TitleContainer != null)
            {
                var greenDot = new Image();
                greenDot.AddToClassList(Unity.Modifier.GraphElements.Node.k_UssClassName + "__green-dot");
                TitleContainer.Insert(0, greenDot);
            }

            viewDataKey = NodeModel.GetId();

            this.AddOverlay();
        }
示例#2
0
        protected override void BuildUI()
        {
            var selectionBorder = new VisualElement();

            selectionBorder.AddToClassList("ge-node__selection-border");
            Add(selectionBorder);

            var contentContainerElement = new VisualElement();

            contentContainerElement.AddToClassList("ge-node__content-container");
            selectionBorder.Add(contentContainerElement);
            m_ContentContainer = contentContainerElement;

            base.BuildUI();

            if (TitleContainer != null)
            {
                // Add an icon and wrap the icon and the title label.

                var iconAndTitleWrapper = new VisualElement();
                iconAndTitleWrapper.AddToClassList("ge-node__icon-title-wrapper");

                var icon = new VisualElement();
                icon.AddToClassList(k_UssClassName + "__icon");
                icon.AddToClassList(NodeModel.IconTypeString);
                iconAndTitleWrapper.Insert(0, icon);

                var tcIndex = TitleContainer.IndexOf(TitleLabel);
                TitleContainer.Insert(tcIndex, iconAndTitleWrapper);
                iconAndTitleWrapper.Add(TitleLabel);
            }

            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Node.uss"));

            if (NodeModel.HasProgress && TitleContainer != null)
            {
                m_CoroutineProgressBar = new ProgressBar();
                m_CoroutineProgressBar.AddToClassList(k_UssClassName + "__progress-bar");
                TitleContainer.Insert(1, m_CoroutineProgressBar);
            }

            this.AddOverlay();
        }
        protected override void BuildUI()
        {
            base.BuildUI();

            m_Pill = new Pill();

            var pillContainer = new VisualElement();

            pillContainer.AddToClassList(k_UssClassName + "__variable");
            pillContainer.Add(m_Pill);

            m_Pill.RegisterCallback <MouseDownEvent>(ShowSearcher);

            // make it clear the ux is not final
            var wipOverlay = new VisualElement {
                pickingMode = PickingMode.Ignore
            };

            wipOverlay.AddToClassList("vs-wip-node-overlay");
            Add(wipOverlay);

            TitleContainer?.Insert(1, pillContainer);
        }