private void ConstructTextureHelper() { textureViewer = UIFactory.CreateVerticalGroup(UIRoot, "TextureViewer", false, false, true, true, 2, new Vector4(5, 5, 5, 5), new Color(0.1f, 0.1f, 0.1f)); UIFactory.SetLayoutElement(textureViewer, flexibleWidth: 9999, flexibleHeight: 9999); // Save helper var saveRowObj = UIFactory.CreateHorizontalGroup(textureViewer, "SaveRow", false, false, true, true, 2, new Vector4(2, 2, 2, 2), new Color(0.1f, 0.1f, 0.1f)); var 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; textureSavePathInput = UIFactory.CreateInputField(saveRowObj, "SaveInput", "..."); UIFactory.SetLayoutElement(textureSavePathInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 9999); // Actual texture viewer var imageObj = UIFactory.CreateUIObject("TextureViewerImage", textureViewer); textureImage = imageObj.AddComponent <Image>(); textureImageLayout = textureImage.gameObject.AddComponent <LayoutElement>(); var fitter = imageObj.AddComponent <ContentSizeFitter>(); fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; textureViewer.SetActive(false); }
public GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateUIObject("LogCell", parent, new Vector2(25, 25)); Rect = UIRoot.GetComponent <RectTransform>(); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 3); UIFactory.SetLayoutElement(UIRoot, minHeight: 25, minWidth: 50, flexibleWidth: 9999); IndexLabel = UIFactory.CreateLabel(UIRoot, "IndexLabel", "i:", TextAnchor.MiddleCenter, Color.grey, false, 12); UIFactory.SetLayoutElement(IndexLabel.gameObject, minHeight: 25, minWidth: 30, flexibleWidth: 40); Input = UIFactory.CreateInputField(UIRoot, "Input", ""); //Input.Component.gameObject.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; UIFactory.SetLayoutElement(Input.UIRoot, minHeight: 25, flexibleWidth: 9999); RuntimeProvider.Instance.SetColorBlock(Input.Component, new Color(0.1f, 0.1f, 0.1f), new Color(0.13f, 0.13f, 0.13f), new Color(0.07f, 0.07f, 0.07f)); Input.Component.GetComponent <Image>().color = new Color(0.2f, 0.2f, 0.2f); Input.Component.readOnly = true; Input.Component.textComponent.supportRichText = true; Input.Component.lineType = InputField.LineType.MultiLineNewline; Input.Component.textComponent.font = UIManager.ConsoleFont; Input.PlaceholderText.font = UIManager.ConsoleFont; return(UIRoot); }
// First row private void ConstructFirstRow(GameObject parent) { var rowObj = UIFactory.CreateUIObject("FirstRow", parent); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(rowObj, true, true, true, true, 5, 2, 2, 2, 2); UIFactory.SetLayoutElement(rowObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); var nameLabel = UIFactory.CreateLabel(rowObj, "NameFilterLabel", "Filter names:", TextAnchor.MiddleLeft, Color.grey); UIFactory.SetLayoutElement(nameLabel.gameObject, minHeight: 25, minWidth: 90, flexibleWidth: 0); filterInputField = UIFactory.CreateInputField(rowObj, "NameFilterInput", "..."); UIFactory.SetLayoutElement(filterInputField.UIRoot, minHeight: 25, flexibleWidth: 300); filterInputField.OnValueChanged += (string val) => { SetFilter(val); }; var spacer = UIFactory.CreateUIObject("Spacer", rowObj); UIFactory.SetLayoutElement(spacer, minWidth: 25); // Update button and toggle var updateButton = UIFactory.CreateButton(rowObj, "UpdateButton", "Update displayed values", new Color(0.22f, 0.28f, 0.22f)); UIFactory.SetLayoutElement(updateButton.Component.gameObject, minHeight: 25, minWidth: 175, flexibleWidth: 0); updateButton.OnClick += UpdateClicked; var toggleObj = UIFactory.CreateToggle(rowObj, "AutoUpdateToggle", out autoUpdateToggle, out Text toggleText); UIFactory.SetLayoutElement(toggleObj, minWidth: 125, minHeight: 25); autoUpdateToggle.isOn = false; toggleText.text = "Auto-update"; }
// 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(); }
// 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); }
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); }
public TypeCompleter(Type baseType, InputFieldRef inputField) { BaseType = baseType; InputField = inputField; inputField.OnValueChanged += OnInputFieldChanged; if (BaseType != null) { CacheTypes(); } }
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 InputFieldScroller(AutoSliderScrollbar sliderScroller, InputFieldRef inputField) { this.Slider = sliderScroller; this.InputField = inputField; inputField.OnValueChanged += OnTextChanged; ContentRect = inputField.UIRoot.GetComponent <RectTransform>(); ViewportRect = ContentRect.transform.parent.GetComponent <RectTransform>(); if (!RootScaler) { RootScaler = UIManager.CanvasRoot.GetComponent <CanvasScaler>(); } }
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); }
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("ArgRow", parent); UIFactory.SetLayoutElement(UIRoot, minHeight: 25, flexibleHeight: 50, minWidth: 50, flexibleWidth: 9999); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 5); UIRoot.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; argNameLabel = UIFactory.CreateLabel(UIRoot, "ArgLabel", "not set", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(argNameLabel.gameObject, minWidth: 40, flexibleWidth: 90, minHeight: 25, flexibleHeight: 50); argNameLabel.horizontalOverflow = HorizontalWrapMode.Wrap; inputField = UIFactory.CreateInputField(UIRoot, "InputField", "..."); UIFactory.SetLayoutElement(inputField.UIRoot, minHeight: 25, flexibleHeight: 50, minWidth: 100, flexibleWidth: 1000); inputField.Component.lineType = InputField.LineType.MultiLineNewline; inputField.UIRoot.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; typeCompleter = new TypeCompleter(typeof(object), this.inputField); typeCompleter.Enabled = false; CreateSpecialContent(); return(UIRoot); }
public override void ConstructUI(GameObject parent) { uiRoot = UIFactory.CreateVerticalGroup(parent, "ObjectSearch", true, true, true, true, 2, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(uiRoot, flexibleHeight: 9999); // Search context row var contextGroup = UIFactory.CreateHorizontalGroup(uiRoot, "SearchContextRow", false, true, true, true, 2, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(contextGroup, minHeight: 25, flexibleHeight: 0); var contextLbl = UIFactory.CreateLabel(contextGroup, "SearchContextLabel", "Searching for:", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(contextLbl.gameObject, minWidth: 110, flexibleWidth: 0); var contextDropObj = UIFactory.CreateDropdown(contextGroup, out Dropdown contextDrop, null, 14, OnContextDropdownChanged); foreach (var name in Enum.GetNames(typeof(SearchContext))) { contextDrop.options.Add(new Dropdown.OptionData(name)); } UIFactory.SetLayoutElement(contextDropObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); // Unity class input unityObjectClassRow = UIFactory.CreateHorizontalGroup(uiRoot, "UnityClassRow", false, true, true, true, 2, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(unityObjectClassRow, minHeight: 25, flexibleHeight: 0); var unityClassLbl = UIFactory.CreateLabel(unityObjectClassRow, "UnityClassLabel", "Class filter:", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(unityClassLbl.gameObject, minWidth: 110, flexibleWidth: 0); var classInputField = UIFactory.CreateInputField(unityObjectClassRow, "ClassInput", "..."); UIFactory.SetLayoutElement(classInputField.UIRoot, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); typeAutocompleter = new TypeCompleter(typeof(UnityEngine.Object), classInputField); classInputField.OnValueChanged += OnTypeInputChanged; //unityObjectClassRow.SetActive(false); // Child filter row childFilterRow = UIFactory.CreateHorizontalGroup(uiRoot, "ChildFilterRow", false, true, true, true, 2, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(childFilterRow, minHeight: 25, flexibleHeight: 0); var childLbl = UIFactory.CreateLabel(childFilterRow, "ChildLabel", "Child filter:", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(childLbl.gameObject, minWidth: 110, flexibleWidth: 0); var childDropObj = UIFactory.CreateDropdown(childFilterRow, out Dropdown childDrop, null, 14, OnChildFilterDropChanged); foreach (var name in Enum.GetNames(typeof(ChildFilter))) { childDrop.options.Add(new Dropdown.OptionData(name)); } UIFactory.SetLayoutElement(childDropObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); childFilterRow.SetActive(false); // Scene filter row sceneFilterRow = UIFactory.CreateHorizontalGroup(uiRoot, "SceneFilterRow", false, true, true, true, 2, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(sceneFilterRow, minHeight: 25, flexibleHeight: 0); var sceneLbl = UIFactory.CreateLabel(sceneFilterRow, "SceneLabel", "Scene filter:", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(sceneLbl.gameObject, minWidth: 110, flexibleWidth: 0); var sceneDropObj = UIFactory.CreateDropdown(sceneFilterRow, out Dropdown sceneDrop, null, 14, OnSceneFilterDropChanged); foreach (var name in Enum.GetNames(typeof(SceneFilter))) { sceneDrop.options.Add(new Dropdown.OptionData(name)); } UIFactory.SetLayoutElement(sceneDropObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); sceneFilterRow.SetActive(false); // Name filter input var nameRow = UIFactory.CreateHorizontalGroup(uiRoot, "NameRow", true, true, true, true, 2, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(nameRow, minHeight: 25, flexibleHeight: 0); var nameLbl = UIFactory.CreateLabel(nameRow, "NameFilterLabel", "Name contains:", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(nameLbl.gameObject, minWidth: 110, flexibleWidth: 0); nameInputField = UIFactory.CreateInputField(nameRow, "NameFilterInput", "..."); UIFactory.SetLayoutElement(nameInputField.UIRoot, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); // Search button var searchButton = UIFactory.CreateButton(uiRoot, "SearchButton", "Search"); UIFactory.SetLayoutElement(searchButton.Component.gameObject, minHeight: 25, flexibleHeight: 0); searchButton.OnClick += DoSearch; // Results count label var resultsCountRow = UIFactory.CreateHorizontalGroup(uiRoot, "ResultsCountRow", true, true, true, true); UIFactory.SetLayoutElement(resultsCountRow, minHeight: 25, flexibleHeight: 0); resultsLabel = UIFactory.CreateLabel(resultsCountRow, "ResultsLabel", "0 results", TextAnchor.MiddleCenter); // RESULTS SCROLL POOL dataHandler = new ButtonListHandler <object, ButtonCell>(resultsScrollPool, GetEntries, SetCell, ShouldDisplayCell, OnCellClicked); resultsScrollPool = UIFactory.CreateScrollPool <ButtonCell>(uiRoot, "ResultsList", out GameObject scrollObj, out GameObject scrollContent); resultsScrollPool.Initialize(dataHandler); UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999); }
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); }
public override void ConstructPanelContent() { // ~~~~~~~~~ Active hooks scroll pool currentHooksPanel = UIFactory.CreateUIObject("CurrentHooksPanel", this.uiContent); UIFactory.SetLayoutElement(currentHooksPanel, flexibleHeight: 9999, flexibleWidth: 9999); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(currentHooksPanel, true, true, true, true); var addRow = UIFactory.CreateHorizontalGroup(currentHooksPanel, "AddRow", false, true, true, true, 4, new Vector4(2, 2, 2, 2), new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(addRow, minHeight: 30, flexibleWidth: 9999); classSelectorInputField = UIFactory.CreateInputField(addRow, "ClassInput", "Enter a class to add hooks to..."); UIFactory.SetLayoutElement(classSelectorInputField.Component.gameObject, flexibleWidth: 9999); new TypeCompleter(typeof(object), classSelectorInputField, true, false); var addButton = UIFactory.CreateButton(addRow, "AddButton", "Add Hooks"); UIFactory.SetLayoutElement(addButton.Component.gameObject, minWidth: 100, minHeight: 25); addButton.OnClick += OnClassInputAddClicked; var hooksLabel = UIFactory.CreateLabel(currentHooksPanel, "HooksLabel", "Current Hooks", TextAnchor.MiddleCenter); UIFactory.SetLayoutElement(hooksLabel.gameObject, minHeight: 30, flexibleWidth: 9999); HooksScrollPool = UIFactory.CreateScrollPool <HookCell>(currentHooksPanel, "HooksScrollPool", out GameObject hooksScroll, out GameObject hooksContent); UIFactory.SetLayoutElement(hooksScroll, flexibleHeight: 9999); HooksScrollPool.Initialize(HookManager.Instance); // ~~~~~~~~~ Add hooks panel addHooksPanel = UIFactory.CreateUIObject("AddHooksPanel", this.uiContent); UIFactory.SetLayoutElement(addHooksPanel, flexibleHeight: 9999, flexibleWidth: 9999); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(addHooksPanel, true, true, true, true); addHooksLabel = UIFactory.CreateLabel(addHooksPanel, "AddLabel", "NOT SET", TextAnchor.MiddleCenter); UIFactory.SetLayoutElement(addHooksLabel.gameObject, minHeight: 30, minWidth: 100, flexibleWidth: 9999); var buttonRow = UIFactory.CreateHorizontalGroup(addHooksPanel, "ButtonRow", false, false, true, true, 5); UIFactory.SetLayoutElement(buttonRow, minHeight: 25, flexibleWidth: 9999); var doneButton = UIFactory.CreateButton(buttonRow, "DoneButton", "Done", new Color(0.2f, 0.3f, 0.2f)); UIFactory.SetLayoutElement(doneButton.Component.gameObject, minHeight: 25, flexibleWidth: 9999); doneButton.OnClick += HookManager.Instance.DoneAddingHooks; AddHooksMethodFilterInput = UIFactory.CreateInputField(addHooksPanel, "FilterInputField", "Filter method names..."); UIFactory.SetLayoutElement(AddHooksMethodFilterInput.Component.gameObject, minHeight: 30, flexibleWidth: 9999); AddHooksMethodFilterInput.OnValueChanged += HookManager.Instance.OnAddHookFilterInputChanged; AddHooksScrollPool = UIFactory.CreateScrollPool <AddHookCell>(addHooksPanel, "MethodAddScrollPool", out GameObject addScrollRoot, out GameObject addContent); UIFactory.SetLayoutElement(addScrollRoot, flexibleHeight: 9999); AddHooksScrollPool.Initialize(HookManager.Instance); addHooksPanel.gameObject.SetActive(false); // ~~~~~~~~~ Hook source editor panel editorPanel = UIFactory.CreateUIObject("HookSourceEditor", this.uiContent); UIFactory.SetLayoutElement(editorPanel, flexibleHeight: 9999, flexibleWidth: 9999); UIFactory.SetLayoutGroup <VerticalLayoutGroup>(editorPanel, true, true, true, true); var editorLabel = UIFactory.CreateLabel(editorPanel, "EditorLabel", "Edit Harmony patch source as desired. Accepted method names are Prefix, Postfix, Finalizer and Transpiler (can define multiple).\n\n" + "Hooks are temporary! Please copy the source into your IDE to avoid losing work if you wish to keep it!", TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(editorLabel.gameObject, minHeight: 25, flexibleWidth: 9999); var editorButtonRow = UIFactory.CreateHorizontalGroup(editorPanel, "ButtonRow", false, false, true, true, 5); UIFactory.SetLayoutElement(editorButtonRow, minHeight: 25, flexibleWidth: 9999); var editorSaveButton = UIFactory.CreateButton(editorButtonRow, "DoneButton", "Save and Return", new Color(0.2f, 0.3f, 0.2f)); UIFactory.SetLayoutElement(editorSaveButton.Component.gameObject, minHeight: 25, flexibleWidth: 9999); editorSaveButton.OnClick += HookManager.Instance.EditorInputSave; var editorDoneButton = UIFactory.CreateButton(editorButtonRow, "DoneButton", "Cancel and Return", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(editorDoneButton.Component.gameObject, minHeight: 25, flexibleWidth: 9999); editorDoneButton.OnClick += HookManager.Instance.EditorInputCancel; int fontSize = 16; var inputObj = UIFactory.CreateScrollInputField(editorPanel, "EditorInput", "", out var inputScroller, fontSize); EditorInputScroller = inputScroller; EditorInput.OnValueChanged += HookManager.Instance.OnEditorInputChanged; EditorInputText = EditorInput.Component.textComponent; EditorInputText.supportRichText = false; EditorInputText.color = Color.clear; EditorInput.Component.customCaretColor = true; EditorInput.Component.caretColor = Color.white; EditorInput.PlaceholderText.fontSize = fontSize; // Lexer highlight text overlay var highlightTextObj = UIFactory.CreateUIObject("HighlightText", EditorInputText.gameObject); var highlightTextRect = highlightTextObj.GetComponent <RectTransform>(); highlightTextRect.pivot = new Vector2(0, 1); highlightTextRect.anchorMin = Vector2.zero; highlightTextRect.anchorMax = Vector2.one; highlightTextRect.offsetMin = Vector2.zero; highlightTextRect.offsetMax = Vector2.zero; EditorHighlightText = highlightTextObj.AddComponent <Text>(); EditorHighlightText.color = Color.white; EditorHighlightText.supportRichText = true; EditorHighlightText.fontSize = fontSize; // Set fonts EditorInputText.font = UniversalUI.ConsoleFont; EditorInput.PlaceholderText.font = UniversalUI.ConsoleFont; EditorHighlightText.font = UniversalUI.ConsoleFont; editorPanel.SetActive(false); }