public Slot buildLayerUI(string name, string type, Slot slot, int depth) { UIBuilder uiBuilder3 = new UIBuilder(slot); uiBuilder3.Style.ForceExpandHeight = false; uiBuilder3.Style.ChildAlignment = Alignment.TopLeft; uiBuilder3.HorizontalLayout(4f, 0.0f, new Alignment?()); uiBuilder3.Style.MinHeight = 32f; uiBuilder3.Style.MinWidth = 32f; Button button1 = uiBuilder3.Button(); Expander expander = button1.Slot.AttachComponent <Expander>(true); TextExpandIndicator textExpandIndicator = button1.Slot.AttachComponent <TextExpandIndicator>(true); textExpandIndicator.Text.Target = (IField <string>)button1.Slot.GetComponentInChildren <Text>((Predicate <Text>)null, false).Content; uiBuilder3.Style.FlexibleWidth = 100f; Text text = uiBuilder3.Text(name, true, Alignment.MiddleLeft, true, (string)null); Button button2 = text.Slot.AttachComponent <Button>(true, (Action <Button>)null); MethodInfo privMethod = logixNodeSelector.GetType().GetMethod("OnOpenCategoryPressed", BindingFlags.NonPublic | BindingFlags.Instance); ButtonEventHandler <string> action = (ButtonEventHandler <string>)Delegate.CreateDelegate(typeof(ButtonEventHandler <string>), logixNodeSelector, privMethod); button2.SetupAction <string>(action, type, 0.3f); InteractionElement.ColorDriver colorDriver = button2.ColorDrivers.Add(); colorDriver.ColorDrive.Target = (IField <color>)text.Color; colorDriver.NormalColor.Value = color.Black; colorDriver.HighlightColor.Value = color.Blue; colorDriver.PressColor.Value = color.Cyan; //button2.SetupAction(new ButtonEventHandler(this.OnSlotNamePressed), 0.0f); //this._slotNameText.Target = text; uiBuilder3.Style.FlexibleWidth = -1f; uiBuilder3.NestOut(); uiBuilder3.Style.MinHeight = -1f; HorizontalLayout horizontalLayout = uiBuilder3.HorizontalLayout(4f, 0.0f, new Alignment?()); uiBuilder3.Style.MinWidth = 32f; uiBuilder3.Empty("Spacer"); uiBuilder3.Style.FlexibleWidth = 100f; //uiBuilder3.VerticalLayout(4f, 0.0f, new Alignment?()); Slot childrenSlot = uiBuilder3.VerticalLayout(4f, 0.0f, new Alignment?()).Slot; expander.SectionRoot.Target = horizontalLayout.Slot; textExpandIndicator.SectionRoot.Target = horizontalLayout.Slot; textExpandIndicator.ChildrenRoot.Target = childrenSlot; //if (depth<2) buildHierarchyLevel(childrenSlot, depth+1); expander.IsExpanded = false; //slot.ActiveSelf = depth == 0; return(childrenSlot); }
private async Task <Rect> BuildComponentUI(Component targetInstance) { UIBuilder ui = new UIBuilder(VisualSlot, 800, 5000, 0.1f); ui.Style.MinHeight = 30f; ui.Style.ForceExpandHeight = false; ui.Image(new color(141 / 255.0f, 186 / 255.0f, 104 / 255.0f)); ui.VerticalLayout(4f, 0, Alignment.TopLeft); ui.Style.MinHeight = 30f; ui.Style.PreferredHeight = 30f; ui.Style.ForceExpandHeight = true; VerticalLayout content = ui.VerticalLayout(4f, 10f, Alignment.TopLeft); ui.Style.ChildAlignment = Alignment.TopLeft; { ui.HorizontalLayout(4f); ui.Style.FlexibleWidth = 1000f; ui.Button("<b>" + targetInstance.GetType().GetNiceName() + "</b>", color.White); ui.Style.FlexibleWidth = 0.0f; ui.Style.MinWidth = 32f; ui.Button("D", MathX.Lerp(color.Green, color.White, 0.7f)); ui.Button("X", MathX.Lerp(color.Red, color.White, 0.7f)); ui.NestOut(); } if (targetInstance is ICustomInspector customInspector) { ui.Style.MinHeight = 24f; customInspector.BuildInspectorUI(ui); } else { WorkerInspector.BuildInspectorUI(targetInstance, ui); } await new Updates(5); return(content.RectTransform.BoundingRect); }
private void CreateScrollListElement(MeshCollider mc) { Slot _elementRoot = _listBuilder.Next("Element"); var _refField = _elementRoot.AttachComponent <ReferenceField <MeshCollider> >(); _refField.Reference.Target = mc; UIBuilder _listBuilder2 = new UIBuilder(_elementRoot); _listBuilder2.NestInto(_elementRoot); _listBuilder2.VerticalLayout(4f, 4f); _listBuilder2.HorizontalLayout(10f); _buttonColor = new color(1f, 1f, 1f); _text = "Jump To"; _listBuilder2.ButtonRef <Slot>(in _text, in _buttonColor, JumpTo, mc.Slot); _text = "Highlight"; _listBuilder2.ButtonRef <Slot>(in _text, in _buttonColor, Highlight, mc.Slot); _text = "Replace"; _listBuilder2.ButtonRef <MeshCollider>(in _text, in _buttonColor, Replace, mc); _text = "Remove"; _listBuilder2.ButtonRef <MeshCollider>(in _text, in _buttonColor, Remove, mc); _listBuilder2.NestOut(); _listBuilder2.NestOut(); _listBuilder2.Current.AttachComponent <RefEditor>().Setup(_refField.Reference); }
protected override void OnAttach() { base.OnAttach(); sep = "\t"; //CONTAINING SLOT AND BASE CANVAS mainSlot = this.LocalUserSpace.AddSlot("LogiX Node Browser"); NeosPanel neosPanel = mainSlot.AttachComponent <NeosPanel>(true, (Action <NeosPanel>)null); neosPanel.Title = "Logix/Componer browser"; neosPanel.Padding.Value = 0.005f; neosPanel.ZPadding.Value = 0.005f; neosPanel.Thickness.Value = 0.01f; neosPanel.AddCloseButton(); neosPanel.AddParentButton(); UIBuilder uiBuilder1 = new UIBuilder(neosPanel.ContentSlot, 1000f, 1000f, 0.0005f); //Canvas component = neosPanel.ContentSlot.GetComponent<Canvas>((Predicate<Canvas>)null, false); color color1 = new color(1f, 1f, 1f, 0.2f); uiBuilder1.Panel(in color1, false); //Search Footer RectTransform searchFooter, mainContent; uiBuilder1.HorizontalFooter(64f, out searchFooter, out mainContent); UIBuilder searchUI = new UIBuilder(searchFooter); TextField textfield = searchUI.TextField(); Action sendRequest = this.BuildSearchLogix(textfield.Text.Content.ReferenceID); var editorEvents = textfield.Slot.AddSlot("logix").AttachComponent <Interaction.TextEditorEvents>(); editorEvents.Source.Value = textfield.Editor; editorEvents.EditingFinished.Target = sendRequest; //MAIN CONTENT //Horizontal split List <RectTransform> rectTransformList = (new UIBuilder(mainContent)).SplitHorizontally(0.4f, 0.6f); //RIGHT SIDE Slot rightSlot = rectTransformList[1].Slot; logixNodeSelector = rightSlot.AttachComponent <LogixNodeSelector2>(); Slot contentSlot = rightSlot.FindChild(s => s.Name == "Content"); Slot containerSlot = contentSlot[0]; nodesContainerSlot = containerSlot; contentSlot.ActiveSelf = false; rightSlot.FindChild(s => s.Name == "Panel").Destroy(); rightSlot.FindChild(s => s.Name == "Handle").Destroy(); rightSlot.FindChild(s => s.Name == "Header").Destroy(); rightSlot.FindChild(s => s.Name == "HandleAnchor").Destroy(); containerSlot.Parent = rightSlot; //LEFT SIDE RectTransform hierarchyHeader, nodeHierarchy; Slot leftSlot = rectTransformList[0].Slot; UIBuilder uiBuilder2 = new UIBuilder(leftSlot); //header uiBuilder2.HorizontalHeader(64f, out hierarchyHeader, out nodeHierarchy); UIBuilder uiBuilder3 = new UIBuilder(hierarchyHeader); uiBuilder3.HorizontalLayout(4f, 0.0f, 4f, 0.0f, 4f, new Alignment?()); uiBuilder3.Style.FlexibleWidth = 100f; //hierarchyHeader = uiBuilder3.CurrentRect; uiBuilder3.HorizontalLayout(4f, 0.0f, 0.0f, 4.0f, 0.0f); //hierarchy container UIBuilder uiBuilderContent = new UIBuilder(nodeHierarchy); color color2 = new color(1f, 1f, 1f, 0.2f); uiBuilderContent.Panel(in color2, false); //nodeHierarchy = uiBuilderContent.CurrentRect; uiBuilderContent.ScrollArea(new Alignment?()); uiBuilderContent.VerticalLayout(4.0f, 0.0f, Alignment.TopLeft); uiBuilderContent.FitContent(SizeFit.Disabled, SizeFit.MinSize); componentHierarchy = uiBuilderContent.CurrentRect.Slot; logixHierarchy = componentHierarchy.Duplicate(); //Logix/Comp buttons uiBuilder3.Style.FlexibleWidth = -1f; uiBuilder3.Style.MinWidth = 64f; Button logixButton = uiBuilder3.Button("LogiX"); var component1 = logixButton.Slot.AttachComponent <ButtonValueSet <bool> >(); component1.TargetValue.Target = logixHierarchy.ActiveSelf_Field; component1.SetValue.Value = true; var component2 = logixButton.Slot.AttachComponent <ButtonValueSet <bool> >(); component2.TargetValue.Target = componentHierarchy.ActiveSelf_Field; component2.SetValue.Value = false; Button compButton = uiBuilder3.Button("Comps"); var component3 = compButton.Slot.AttachComponent <ButtonValueSet <bool> >(); component3.TargetValue.Target = logixHierarchy.ActiveSelf_Field; component3.SetValue.Value = false; var component4 = compButton.Slot.AttachComponent <ButtonValueSet <bool> >(); component4.TargetValue.Target = componentHierarchy.ActiveSelf_Field; component4.SetValue.Value = true; components_string2 = "NiceName" + sep + "Name" + sep + "FullName" + sep + "Folder" + sep + "Description" + sep + "Type\n"; logix_string2 = components_string2; buildLayer("", componentHierarchy); buildLayer("/LogiX", logixHierarchy); componentHierarchy.ActiveSelf = false; logixHierarchy.ActiveSelf = true; components_string += "\n "; logix_string += "\n "; //components_string2 += "\n "; //logix_string2 += "\n "; System.IO.File.WriteAllText(@"C:\Program Files (x86)\Steam\steamapps\common\NeosVR\components_string.txt", components_string); System.IO.File.WriteAllText(@"C:\Program Files (x86)\Steam\steamapps\common\NeosVR\logix_string.txt", logix_string); System.IO.File.WriteAllText(@"C:\Program Files (x86)\Steam\steamapps\common\NeosVR\components_string2.txt", components_string2); System.IO.File.WriteAllText(@"C:\Program Files (x86)\Steam\steamapps\common\NeosVR\logix_string2.txt", logix_string2); //this.MakeVariableSelector(); }