public override GameObject CreateContent(GameObject parent) { var root = base.CreateContent(parent); // Add mask to button so text doesnt overlap on Close button //this.Button.Component.gameObject.AddComponent<Mask>().showMaskGraphic = true; this.Button.ButtonText.horizontalOverflow = HorizontalWrapMode.Wrap; // Behaviour toggle var toggleObj = UIFactory.CreateToggle(UIRoot, "BehaviourToggle", out BehaviourToggle, out var behavText); UIFactory.SetLayoutElement(toggleObj, minHeight: 25, minWidth: 25); BehaviourToggle.onValueChanged.AddListener(BehaviourToggled); // put at first object toggleObj.transform.SetSiblingIndex(0); // Destroy button DestroyButton = UIFactory.CreateButton(UIRoot, "DestroyButton", "X", new Color(0.3f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(DestroyButton.Component.gameObject, minHeight: 21, minWidth: 25); DestroyButton.OnClick += DestroyClicked; return(root); }
// UI construction public virtual GameObject CreateContent(GameObject uiRoot) { UIRoot = UIFactory.CreateUIObject("UnityObjectRow", uiRoot); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 5); UIFactory.SetLayoutElement(UIRoot, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); var nameLabel = UIFactory.CreateLabel(UIRoot, "NameLabel", "Name:", TextAnchor.MiddleLeft, Color.grey); UIFactory.SetLayoutElement(nameLabel.gameObject, minHeight: 25, minWidth: 45, flexibleWidth: 0); nameInput = UIFactory.CreateInputField(UIRoot, "NameInput", "untitled"); UIFactory.SetLayoutElement(nameInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 1000); nameInput.Component.readOnly = true; gameObjectButton = UIFactory.CreateButton(UIRoot, "GameObjectButton", "Inspect GameObject", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(gameObjectButton.Component.gameObject, minHeight: 25, minWidth: 160); gameObjectButton.OnClick += OnGameObjectButtonClicked; var instanceLabel = UIFactory.CreateLabel(UIRoot, "InstanceLabel", "Instance ID:", TextAnchor.MiddleRight, Color.grey); UIFactory.SetLayoutElement(instanceLabel.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); instanceIdInput = UIFactory.CreateInputField(UIRoot, "InstanceIDInput", "ERROR"); UIFactory.SetLayoutElement(instanceIdInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 0); instanceIdInput.Component.readOnly = true; UIRoot.SetActive(false); return(UIRoot); }
// UI construction private void ConstructUnityObjectRow() { unityObjectRow = UIFactory.CreateUIObject("UnityObjectRow", UIRoot); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(unityObjectRow, false, false, true, true, 5); UIFactory.SetLayoutElement(unityObjectRow, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); textureButton = UIFactory.CreateButton(unityObjectRow, "TextureButton", "View Texture", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(textureButton.Component.gameObject, minHeight: 25, minWidth: 150); textureButton.OnClick += ToggleTextureViewer; var nameLabel = UIFactory.CreateLabel(unityObjectRow, "NameLabel", "Name:", TextAnchor.MiddleLeft, Color.grey); UIFactory.SetLayoutElement(nameLabel.gameObject, minHeight: 25, minWidth: 45, flexibleWidth: 0); nameInput = UIFactory.CreateInputField(unityObjectRow, "NameInput", "untitled"); UIFactory.SetLayoutElement(nameInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 1000); nameInput.Component.readOnly = true; gameObjectButton = UIFactory.CreateButton(unityObjectRow, "GameObjectButton", "Inspect GameObject", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(gameObjectButton.Component.gameObject, minHeight: 25, minWidth: 160); gameObjectButton.OnClick += OnGameObjectButtonClicked; var instanceLabel = UIFactory.CreateLabel(unityObjectRow, "InstanceLabel", "Instance ID:", TextAnchor.MiddleRight, Color.grey); UIFactory.SetLayoutElement(instanceLabel.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); instanceIdInput = UIFactory.CreateInputField(unityObjectRow, "InstanceIDInput", "ERROR"); UIFactory.SetLayoutElement(instanceIdInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 0); instanceIdInput.Component.readOnly = true; unityObjectRow.SetActive(false); ConstructTextureHelper(); }
public GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateUIObject(this.GetType().Name, parent, new Vector2(100, 30)); Rect = UIRoot.GetComponent <RectTransform>(); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 4, childAlignment: TextAnchor.UpperLeft); UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600); UIRoot.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; MethodNameLabel = UIFactory.CreateLabel(UIRoot, "MethodName", "NOT SET", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(MethodNameLabel.gameObject, minHeight: 25, flexibleWidth: 9999); ToggleActiveButton = UIFactory.CreateButton(UIRoot, "ToggleActiveBtn", "Enabled", new Color(0.15f, 0.2f, 0.15f)); UIFactory.SetLayoutElement(ToggleActiveButton.Component.gameObject, minHeight: 25, minWidth: 100); ToggleActiveButton.OnClick += OnToggleActiveClicked; DeleteButton = UIFactory.CreateButton(UIRoot, "DeleteButton", "Delete", new Color(0.2f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(DeleteButton.Component.gameObject, minHeight: 25, minWidth: 100); DeleteButton.OnClick += OnDeleteClicked; EditPatchButton = UIFactory.CreateButton(UIRoot, "EditButton", "Edit Hook Source", new Color(0.15f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(EditPatchButton.Component.gameObject, minHeight: 25, minWidth: 150); EditPatchButton.OnClick += OnEditPatchClicked; return(UIRoot); }
public override GameObject CreateContent(GameObject uiRoot) { GameObject ret = base.CreateContent(uiRoot); // Toggle Button toggleButton = UIFactory.CreateButton(UIRoot, "AudioWidgetToggleButton", "Show Player", new Color(0.2f, 0.3f, 0.2f)); toggleButton.Transform.SetSiblingIndex(0); UIFactory.SetLayoutElement(toggleButton.Component.gameObject, minHeight: 25, minWidth: 170); toggleButton.OnClick += ToggleAudioWidget; // Actual widget audioPlayerRoot = UIFactory.CreateVerticalGroup(uiRoot, "AudioWidget", false, false, true, true, spacing: 5); UIFactory.SetLayoutElement(audioPlayerRoot, flexibleWidth: 9999, flexibleHeight: 50); audioPlayerRoot.SetActive(false); // Player GameObject playerRow = UIFactory.CreateHorizontalGroup(audioPlayerRoot, "PlayerWidget", false, false, true, true, spacing: 5, padding: new() { x = 3f, w = 3f, y = 3f, z = 3f }); playStopButton = UIFactory.CreateButton(playerRow, "PlayerButton", "Play", normalColor: new(0.2f, 0.4f, 0.2f)); playStopButton.OnClick += OnPlayStopClicked; UIFactory.SetLayoutElement(playStopButton.GameObject, minWidth: 60, minHeight: 25); progressLabel = UIFactory.CreateLabel(playerRow, "ProgressLabel", "0 / 0"); UIFactory.SetLayoutElement(progressLabel.gameObject, flexibleWidth: 9999, minHeight: 25); ResetProgressLabel(); // Save helper saveObjectRow = UIFactory.CreateHorizontalGroup(audioPlayerRoot, "SaveRow", false, false, true, true, 2, new Vector4(2, 2, 2, 2), new Color(0.1f, 0.1f, 0.1f)); ButtonRef saveBtn = UIFactory.CreateButton(saveObjectRow, "SaveButton", "Save .WAV", new Color(0.2f, 0.25f, 0.2f)); UIFactory.SetLayoutElement(saveBtn.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); saveBtn.OnClick += OnSaveClipClicked; savePathInput = UIFactory.CreateInputField(saveObjectRow, "SaveInput", "..."); UIFactory.SetLayoutElement(savePathInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 9999); // cant save label cantSaveRow = UIFactory.CreateHorizontalGroup(audioPlayerRoot, "CantSaveRow", true, true, true, true); UIFactory.SetLayoutElement(cantSaveRow, minHeight: 25, flexibleWidth: 9999); UIFactory.CreateLabel( cantSaveRow, "CantSaveLabel", "Cannot save this AudioClip as the data is compressed or streamed. Try a tool such as AssetRipper to unpack it.", color: Color.grey); return(ret); }
// UI Construction public override GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveValueStruct", false, false, true, true, 3, new Vector4(4, 4, 4, 4), new Color(0.06f, 0.06f, 0.06f), TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(UIRoot, minHeight: 25, flexibleWidth: 9999); applyButton = UIFactory.CreateButton(UIRoot, "ApplyButton", "Apply", new Color(0.2f, 0.27f, 0.2f)); UIFactory.SetLayoutElement(applyButton.Component.gameObject, minHeight: 25, minWidth: 175); applyButton.OnClick += OnApplyClicked; return(UIRoot); }
protected override void ConstructEvaluateHolder(GameObject parent) { // Evaluate vert group EvaluateHolder = UIFactory.CreateUIObject("EvalGroup", parent); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(EvaluateHolder, false, false, true, true, 3); UIFactory.SetLayoutElement(EvaluateHolder, minHeight: 25, flexibleWidth: 9999, flexibleHeight: 775); EvaluateButton = UIFactory.CreateButton(EvaluateHolder, "EvaluateButton", "Evaluate", new Color(0.15f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(EvaluateButton.Component.gameObject, minWidth: 100, minHeight: 25); EvaluateButton.OnClick += EvaluateClicked; }
public override GameObject CreateContent(GameObject uiRoot) { GameObject ret = base.CreateContent(uiRoot); // Button toggleButton = UIFactory.CreateButton(UIRoot, "TextureButton", "View Texture", new Color(0.2f, 0.3f, 0.2f)); toggleButton.Transform.SetSiblingIndex(0); UIFactory.SetLayoutElement(toggleButton.Component.gameObject, minHeight: 25, minWidth: 150); toggleButton.OnClick += ToggleTextureViewer; // Texture viewer textureViewerRoot = UIFactory.CreateVerticalGroup(uiRoot, "TextureViewer", false, false, true, true, 2, new Vector4(5, 5, 5, 5), new Color(0.1f, 0.1f, 0.1f), childAlignment: TextAnchor.UpperLeft); UIFactory.SetLayoutElement(textureViewerRoot, flexibleWidth: 9999, flexibleHeight: 9999); // Save helper GameObject saveRowObj = UIFactory.CreateHorizontalGroup(textureViewerRoot, "SaveRow", false, false, true, true, 2, new Vector4(2, 2, 2, 2), new Color(0.1f, 0.1f, 0.1f)); ButtonRef saveBtn = UIFactory.CreateButton(saveRowObj, "SaveButton", "Save .PNG", new Color(0.2f, 0.25f, 0.2f)); UIFactory.SetLayoutElement(saveBtn.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); saveBtn.OnClick += OnSaveTextureClicked; savePathInput = UIFactory.CreateInputField(saveRowObj, "SaveInput", "..."); UIFactory.SetLayoutElement(savePathInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 9999); // Actual texture viewer GameObject imageViewport = UIFactory.CreateVerticalGroup(textureViewerRoot, "ImageViewport", false, false, true, true, bgColor: new(1, 1, 1, 0), childAlignment: TextAnchor.MiddleCenter); UIFactory.SetLayoutElement(imageViewport, flexibleWidth: 9999, flexibleHeight: 9999); GameObject imageHolder = UIFactory.CreateUIObject("ImageHolder", imageViewport); imageLayout = UIFactory.SetLayoutElement(imageHolder, 1, 1, 0, 0); var actualImageObj = UIFactory.CreateUIObject("ActualImage", imageHolder); var actualRect = actualImageObj.GetComponent <RectTransform>(); actualRect.anchorMin = new(0, 0); actualRect.anchorMax = new(1, 1); image = actualImageObj.AddComponent <Image>(); textureViewerRoot.SetActive(false); return(ret); }
public override GameObject CreateContent(GameObject parent) { var root = base.CreateContent(parent); Image = root.AddComponent <Image>(); this.NameLayout.minWidth = 70; this.NameLayout.flexibleWidth = 0; this.NameLayout.minHeight = 30; this.NameLayout.flexibleHeight = 0; this.NameLabel.alignment = TextAnchor.MiddleRight; this.RightGroupLayout.minWidth = AdjustedWidth * 0.55f; // Key area var keyGroup = UIFactory.CreateUIObject("KeyHolder", root.transform.Find("HoriGroup").gameObject); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(keyGroup, false, false, true, true, 2, 0, 0, 4, 4, childAlignment: TextAnchor.MiddleLeft); KeyGroupLayout = UIFactory.SetLayoutElement(keyGroup, minHeight: 30, minWidth: (int)(AdjustedWidth * 0.44f), flexibleWidth: 0); // set to be after the NameLabel (our index label), and before the main horizontal group. keyGroup.transform.SetSiblingIndex(1); // key Inspect KeyInspectButton = UIFactory.CreateButton(keyGroup, "KeyInspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(KeyInspectButton.Component.gameObject, minWidth: 60, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0); KeyInspectButton.OnClick += KeyInspectClicked; // label KeyLabel = UIFactory.CreateLabel(keyGroup, "KeyLabel", "<i>empty</i>", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(KeyLabel.gameObject, minWidth: 50, flexibleWidth: 999, minHeight: 25); // Type label for input field KeyInputTypeLabel = UIFactory.CreateLabel(keyGroup, "InputTypeLabel", "<i>null</i>", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(KeyInputTypeLabel.gameObject, minWidth: 55, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0); // input field KeyInputField = UIFactory.CreateInputField(keyGroup, "KeyInput", "empty"); UIFactory.SetLayoutElement(KeyInputField.UIRoot, minHeight: 25, flexibleHeight: 0, flexibleWidth: 0, preferredWidth: 200); //KeyInputField.lineType = InputField.LineType.MultiLineNewline; KeyInputField.Component.readOnly = true; return(root); }
private object OnButtonRef(ButtonRef buttonRef) { INiCommandBarControl control; ErrorUtil.ThrowOnFailure(_commandManager.FindCommandBarControl( buttonRef.Guid, out control )); if (control == null) { throw new NetIdeException(String.Format(NeutralResources.CannotFindCommand, buttonRef.Guid)); } return(control); }
public GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateUIObject(this.GetType().Name, parent, new Vector2(100, 30)); Rect = UIRoot.GetComponent <RectTransform>(); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 5, childAlignment: TextAnchor.UpperLeft); UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600); UIRoot.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; HookedLabel = UIFactory.CreateLabel(UIRoot, "HookedLabel", "✓", TextAnchor.MiddleCenter, Color.green); UIFactory.SetLayoutElement(HookedLabel.gameObject, minHeight: 25, minWidth: 100); HookButton = UIFactory.CreateButton(UIRoot, "HookButton", "Hook", new Color(0.2f, 0.25f, 0.2f)); UIFactory.SetLayoutElement(HookButton.Component.gameObject, minHeight: 25, minWidth: 100); HookButton.OnClick += OnHookClicked; MethodNameLabel = UIFactory.CreateLabel(UIRoot, "MethodName", "NOT SET", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(MethodNameLabel.gameObject, minHeight: 25, flexibleWidth: 9999); return(UIRoot); }
public GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateUIObject("TransformCell", parent); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, true, true, true, true, 2, childAlignment: TextAnchor.MiddleCenter); Rect = UIRoot.GetComponent <RectTransform>(); Rect.anchorMin = new Vector2(0, 1); Rect.anchorMax = new Vector2(0, 1); Rect.pivot = new Vector2(0.5f, 1); Rect.sizeDelta = new Vector2(25, 25); UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0); var spacerObj = UIFactory.CreateUIObject("Spacer", UIRoot, new Vector2(0, 0)); UIFactory.SetLayoutElement(spacerObj, minWidth: 0, flexibleWidth: 0, minHeight: 0, flexibleHeight: 0); this.spacer = spacerObj.GetComponent <LayoutElement>(); ExpandButton = UIFactory.CreateButton(this.UIRoot, "ExpandButton", "►"); UIFactory.SetLayoutElement(ExpandButton.Component.gameObject, minWidth: 15, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0); NameButton = UIFactory.CreateButton(this.UIRoot, "NameButton", "Name", null); UIFactory.SetLayoutElement(NameButton.Component.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0); var nameLabel = NameButton.Component.GetComponentInChildren <Text>(); nameLabel.horizontalOverflow = HorizontalWrapMode.Overflow; nameLabel.alignment = TextAnchor.MiddleLeft; Color normal = new Color(0.11f, 0.11f, 0.11f); Color highlight = new Color(0.25f, 0.25f, 0.25f); Color pressed = new Color(0.05f, 0.05f, 0.05f); Color disabled = new Color(1, 1, 1, 0); RuntimeProvider.Instance.SetColorBlock(ExpandButton.Component, normal, highlight, pressed, disabled); RuntimeProvider.Instance.SetColorBlock(NameButton.Component, normal, highlight, pressed, disabled); NameButton.OnClick += OnMainButtonClicked; ExpandButton.OnClick += OnExpandClicked; UIRoot.SetActive(false); return(this.UIRoot); }
public override GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveString", false, false, true, true, 3, new Vector4(4, 4, 4, 4), new Color(0.06f, 0.06f, 0.06f)); // Save to file helper SaveFileRow = UIFactory.CreateUIObject("SaveFileRow", UIRoot); UIFactory.SetLayoutElement(SaveFileRow, flexibleWidth: 9999); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(SaveFileRow, false, true, true, true, 3); UIFactory.CreateLabel(SaveFileRow, "Info", "<color=red>String is too long! Save to file if you want to see the full string.</color>", TextAnchor.MiddleLeft); var horizRow = UIFactory.CreateUIObject("Horiz", SaveFileRow); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(horizRow, false, false, true, true, 4); var saveButton = UIFactory.CreateButton(horizRow, "SaveButton", "Save file"); UIFactory.SetLayoutElement(saveButton.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); saveButton.OnClick += OnSaveFileClicked; SaveFilePath = UIFactory.CreateInputField(horizRow, "SaveInput", "..."); UIFactory.SetLayoutElement(SaveFilePath.UIRoot, minHeight: 25, flexibleWidth: 9999); // Main Input / apply ApplyButton = UIFactory.CreateButton(UIRoot, "ApplyButton", "Apply", new Color(0.2f, 0.27f, 0.2f)); UIFactory.SetLayoutElement(ApplyButton.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); ApplyButton.OnClick += OnApplyClicked; inputField = UIFactory.CreateInputField(UIRoot, "InputField", "empty"); inputField.UIRoot.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; UIFactory.SetLayoutElement(inputField.UIRoot, minHeight: 25, flexibleHeight: 500, flexibleWidth: 9999); inputField.Component.lineType = InputField.LineType.MultiLineNewline; inputField.OnValueChanged += OnInputChanged; return(UIRoot); }
public GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateUIObject("TransformCell", parent); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 2, childAlignment: TextAnchor.MiddleCenter); Rect = UIRoot.GetComponent <RectTransform>(); Rect.anchorMin = new Vector2(0, 1); Rect.anchorMax = new Vector2(0, 1); Rect.pivot = new Vector2(0.5f, 1); Rect.sizeDelta = new Vector2(25, 25); UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0); GameObject spacerObj = UIFactory.CreateUIObject("Spacer", UIRoot, new Vector2(0, 0)); UIFactory.SetLayoutElement(spacerObj, minWidth: 0, flexibleWidth: 0, minHeight: 0, flexibleHeight: 0); this.spacer = spacerObj.GetComponent <LayoutElement>(); // Expand arrow ExpandButton = UIFactory.CreateButton(this.UIRoot, "ExpandButton", "►"); UIFactory.SetLayoutElement(ExpandButton.Component.gameObject, minWidth: 15, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0); // Enabled toggle GameObject toggleObj = UIFactory.CreateToggle(UIRoot, "BehaviourToggle", out EnabledToggle, out Text behavText, default, 17, 17);
private object OnButtonRef(ButtonRef buttonRef) { INiCommandBarControl control; ErrorUtil.ThrowOnFailure(_commandManager.FindCommandBarControl( buttonRef.Guid, out control )); if (control == null) throw new NetIdeException(String.Format(NeutralResources.CannotFindCommand, buttonRef.Guid)); return control; }
public virtual GameObject CreateContent(GameObject parent) { // Main layout UIRoot = UIFactory.CreateUIObject(this.GetType().Name, parent, new Vector2(100, 30)); Rect = UIRoot.GetComponent <RectTransform>(); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(UIRoot, false, false, true, true, childAlignment: TextAnchor.UpperLeft); UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600); UIRoot.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; var horiRow = UIFactory.CreateUIObject("HoriGroup", UIRoot); UIFactory.SetLayoutElement(horiRow, minHeight: 29, flexibleHeight: 150, flexibleWidth: 9999); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(horiRow, false, false, true, true, 5, 2, childAlignment: TextAnchor.UpperLeft); horiRow.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; // Left name label NameLabel = UIFactory.CreateLabel(horiRow, "NameLabel", "<notset>", TextAnchor.MiddleLeft); NameLabel.horizontalOverflow = HorizontalWrapMode.Wrap; UIFactory.SetLayoutElement(NameLabel.gameObject, minHeight: 25, minWidth: 20, flexibleHeight: 300, flexibleWidth: 0); NameLayout = NameLabel.GetComponent <LayoutElement>(); // Right vertical group var rightGroupHolder = UIFactory.CreateUIObject("RightGroup", horiRow); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(rightGroupHolder, false, false, true, true, 4, childAlignment: TextAnchor.UpperLeft); UIFactory.SetLayoutElement(rightGroupHolder, minHeight: 25, minWidth: 200, flexibleWidth: 9999, flexibleHeight: 800); RightGroupLayout = rightGroupHolder.GetComponent <LayoutElement>(); ConstructEvaluateHolder(rightGroupHolder); // Right horizontal group var rightHoriGroup = UIFactory.CreateUIObject("RightHoriGroup", rightGroupHolder); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(rightHoriGroup, false, false, true, true, 4, childAlignment: TextAnchor.UpperLeft); UIFactory.SetLayoutElement(rightHoriGroup, minHeight: 25, minWidth: 200, flexibleWidth: 9999, flexibleHeight: 800); SubContentButton = UIFactory.CreateButton(rightHoriGroup, "SubContentButton", "▲", subInactiveColor); UIFactory.SetLayoutElement(SubContentButton.Component.gameObject, minWidth: 25, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0); SubContentButton.OnClick += SubContentClicked; // Type label TypeLabel = UIFactory.CreateLabel(rightHoriGroup, "ReturnLabel", "<notset>", TextAnchor.MiddleLeft); TypeLabel.horizontalOverflow = HorizontalWrapMode.Wrap; UIFactory.SetLayoutElement(TypeLabel.gameObject, minHeight: 25, flexibleHeight: 150, minWidth: 60, flexibleWidth: 0); // Bool and number value interaction var toggleObj = UIFactory.CreateToggle(rightHoriGroup, "Toggle", out Toggle, out ToggleText); UIFactory.SetLayoutElement(toggleObj, minWidth: 70, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0); ToggleText.color = SignatureHighlighter.KeywordBlue; Toggle.onValueChanged.AddListener(ToggleClicked); InputField = UIFactory.CreateInputField(rightHoriGroup, "InputField", "..."); UIFactory.SetLayoutElement(InputField.UIRoot, minWidth: 150, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0); // Apply ApplyButton = UIFactory.CreateButton(rightHoriGroup, "ApplyButton", "Apply", new Color(0.15f, 0.19f, 0.15f)); UIFactory.SetLayoutElement(ApplyButton.Component.gameObject, minWidth: 70, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0); ApplyButton.OnClick += ApplyClicked; // Inspect InspectButton = UIFactory.CreateButton(rightHoriGroup, "InspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(InspectButton.Component.gameObject, minWidth: 70, flexibleWidth: 0, minHeight: 25); InspectButton.OnClick += InspectClicked; // Main value label ValueLabel = UIFactory.CreateLabel(rightHoriGroup, "ValueLabel", "Value goes here", TextAnchor.MiddleLeft); ValueLabel.horizontalOverflow = HorizontalWrapMode.Wrap; UIFactory.SetLayoutElement(ValueLabel.gameObject, minHeight: 25, flexibleHeight: 150, flexibleWidth: 9999); // Subcontent SubContentHolder = UIFactory.CreateUIObject("SubContent", UIRoot); UIFactory.SetLayoutElement(SubContentHolder.gameObject, minHeight: 30, flexibleHeight: 600, minWidth: 100, flexibleWidth: 9999); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(SubContentHolder, true, true, true, true, 2, childAlignment: TextAnchor.UpperLeft); //SubContentHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.MinSize; SubContentHolder.SetActive(false); // Bottom separator var separator = UIFactory.CreateUIObject("BottomSeperator", UIRoot); UIFactory.SetLayoutElement(separator, minHeight: 1, flexibleHeight: 0, flexibleWidth: 9999); separator.AddComponent <Image>().color = Color.black; return(UIRoot); }
// UI Construction public void ConstructUI() { //this.Enabled = true; if (NavButtonWanted) { // create navbar button NavButton = UIFactory.CreateButton(UIManager.NavbarTabButtonHolder, $"Button_{PanelType}", Name); var navBtn = NavButton.Component.gameObject; navBtn.AddComponent <ContentSizeFitter>().horizontalFit = ContentSizeFitter.FitMode.PreferredSize; UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(navBtn, false, true, true, true, 0, 0, 0, 5, 5, TextAnchor.MiddleCenter); UIFactory.SetLayoutElement(navBtn, minWidth: 80); RuntimeProvider.Instance.SetColorBlock(NavButton.Component, UIManager.disabledButtonColor, UIManager.disabledButtonColor * 1.2f); NavButton.OnClick += () => { UIManager.TogglePanel(PanelType); }; var txtObj = navBtn.transform.Find("Text").gameObject; txtObj.AddComponent <ContentSizeFitter>().horizontalFit = ContentSizeFitter.FitMode.PreferredSize; } // create core canvas uiRoot = UIFactory.CreatePanel(Name, out GameObject panelContent); Rect = this.uiRoot.GetComponent <RectTransform>(); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(this.uiRoot, false, false, true, true, 0, 2, 2, 2, 2, TextAnchor.UpperLeft); int id = this.uiRoot.transform.GetInstanceID(); transformToPanelDict.Add(id, this); content = panelContent; UIFactory.SetLayoutGroup <VerticalLayoutGroup>(this.content, false, false, true, true, 2, 2, 2, 2, 2, TextAnchor.UpperLeft); // Title bar titleBar = UIFactory.CreateHorizontalGroup(content, "TitleBar", false, true, true, true, 2, new Vector4(2, 2, 2, 2), new Color(0.06f, 0.06f, 0.06f)); UIFactory.SetLayoutElement(titleBar, minHeight: 25, flexibleHeight: 0); // Title text var titleTxt = UIFactory.CreateLabel(titleBar, "TitleBar", Name, TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(titleTxt.gameObject, minWidth: 250, minHeight: 25, flexibleHeight: 0); // close button var closeHolder = UIFactory.CreateUIObject("CloseHolder", titleBar); UIFactory.SetLayoutElement(closeHolder, minHeight: 25, flexibleHeight: 0, minWidth: 30, flexibleWidth: 9999); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(closeHolder, false, false, true, true, 3, childAlignment: TextAnchor.MiddleRight); var closeBtn = UIFactory.CreateButton(closeHolder, "CloseButton", "—"); UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0); RuntimeProvider.Instance.SetColorBlock(closeBtn.Component, new Color(0.33f, 0.32f, 0.31f)); closeBtn.OnClick += () => { UIManager.SetPanelActive(this.PanelType, false); SaveToConfigManager(); }; if (!CanDragAndResize) { titleBar.SetActive(false); } // Panel dragger Dragger = new PanelDragger(titleBar.GetComponent <RectTransform>(), Rect, this); Dragger.OnFinishResize += OnFinishResize; Dragger.OnFinishDrag += OnFinishDrag; // content (abstract) ConstructPanelContent(); UIManager.SetPanelActive(this.PanelType, true); UIManager.SetPanelActive(this.PanelType, false); UIManager.SetPanelActive(this.PanelType, ShowByDefault); ApplyingSaveData = true; SetTransformDefaults(); // apply panel save data or revert to default try { ApplySaveData(GetSaveDataFromConfigManager()); } catch (Exception ex) { ExplorerCore.Log($"Exception loading panel save data: {ex}"); SetTransformDefaults(); } LayoutRebuilder.ForceRebuildLayoutImmediate(this.Rect); // ensure initialized position is valid EnsureValidSize(); EnsureValidPosition(this.Rect); // update dragger and save data Dragger.OnEndResize(); // simple listener for saving enabled state this.OnToggleEnabled += (bool val) => { SaveToConfigManager(); }; ApplyingSaveData = false; }