/// <inheritdoc /> protected override void BuildPartUI(VisualElement container) { if (!(m_Model is INodeModel nodeModel)) { return; } m_Root = new VisualElement { name = PartName }; m_Root.AddToClassList(ussClassName); m_Root.AddToClassList(m_ParentClassName.WithUssElement(PartName)); TitleContainer = new VisualElement(); TitleContainer.AddToClassList(ussClassName.WithUssElement("title-container")); TitleContainer.AddToClassList(m_ParentClassName.WithUssElement("title-container")); m_Root.Add(TitleContainer); var icon = new VisualElement(); icon.AddToClassList(ussClassName.WithUssElement("icon")); icon.AddToClassList(m_ParentClassName.WithUssElement("icon")); if (!string.IsNullOrEmpty(nodeModel.IconTypeString)) { icon.AddToClassList(ussClassName.WithUssElement("icon").WithUssModifier(nodeModel.IconTypeString)); icon.AddToClassList(m_ParentClassName.WithUssElement("icon").WithUssModifier(nodeModel.IconTypeString)); } TitleContainer.Add(icon); if (HasEditableLabel) { TitleLabel = new EditableLabel { name = titleLabelName }; TitleLabel.RegisterCallback <ChangeEvent <string> >(OnRename); } else { TitleLabel = new Label { name = titleLabelName }; } TitleLabel.AddToClassList(ussClassName.WithUssElement("title")); TitleLabel.AddToClassList(m_ParentClassName.WithUssElement("title")); TitleContainer.Add(TitleLabel); if (nodeModel is IHasProgress hasProgress && hasProgress.HasProgress) { CoroutineProgressBar = new ProgressBar(); CoroutineProgressBar.AddToClassList(ussClassName.WithUssElement("progress-bar")); CoroutineProgressBar.AddToClassList(m_ParentClassName.WithUssElement("progress-bar")); TitleContainer.Add(CoroutineProgressBar); } container.Add(m_Root); }
public StackVisualizerView() : base($"{SceneManagementPackage.StackVisualizerPath}/StackVisualizerView") { Root.AddToClassList(StackVisualizerViewUss.RootClass); m_Header = new Label(); m_Header.AddToClassList(StackVisualizerViewUss.StackTitleClass); m_Container = new VisualElement(); m_Container.AddToClassList(StackVisualizerViewUss.ContainerClass); m_ProgressBar = new ProgressBar(); m_ProgressBar.AddToClassList(StackVisualizerViewUss.ProgressBarClass); Root.Add(m_Header); Root.Add(m_Container); Root.Add(m_ProgressBar); m_ProgressBar.style.display = DisplayStyle.None; }
VisualElement GetTableMissionItemVE(TableMissionItem data) { VisualElement ve = new VisualElement(); ve.AddToClassList("progressItem"); Label label = new Label("-"); label.AddToClassList("label"); ProgressBar progressBar = new ProgressBar() { title = "0%" }; progressBar.AddToClassList("progress"); var p = progressBar.Q(className: "unity-progress-bar__progress"); VisualElement barVe = new VisualElement(); barVe.AddToClassList("progressBar"); p.Add(barVe); Button btn = new Button(() => RemoveMission(data)) { text = "-" }; btn.AddToClassList("btn"); data.label = label; data.bar = progressBar; data.container = ve; ve.Add(label); ve.Add(progressBar); ve.Add(btn); return(ve); void RemoveMission(TableMissionItem d) { missionList.Remove(d); FreshMissionList(); } }
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(); }