static void OnSettingsOptionsLoaded() { if (SaveLoad.settingsSaveState.SaveStateContainsKey(UIManagerSettingsSaveKey)) { uiSettings = (UIOptions)SaveLoad.settingsSaveState.LoadSaveStateObject(UIManagerSettingsSaveKey); if (onUIColorChange != null) { onUIColorChange(); } } }
/// <summary> /// Handler for AcceptButton Click event /// </summary> private void OnAcceptClick(object sender, EventArgs e) { // Handle non-bindable fields UIOptions.Options.InternalProgram = (InternalProgramComboBox.SelectedItem as InternalProgramComboBoxItem)?.Name ?? InternalProgram.DiscImageCreator.ToString(); UIOptions.Options.Password = RedumpPasswordBox.Password; UIOptions.Save(); Hide(); (Owner as MainWindow).OnOptionsUpdated(); }
// Use this for initialization void Awake() { Input.backButtonLeavesApp = true; self = this; colorMap[0] = Color.green; colorMap[1] = Color.blue; colorMap[2] = new Color(0f, 1f, 1f); colorMap[3] = Color.black; colorMap[4] = Color.red; colorMap[5] = new Color(1f, 0f, 1f); colorMap[6] = new Color(1f, 1f, 0f); Mesh tileMesh = TilePrefab.GetComponent <MeshFilter>().sharedMesh; baseMainVerts = tileMesh.vertices; convertToSides(tileMesh, baseMainVerts, ref sideVerts); tileMesh.vertices = baseMainVerts; sideView = false; inventory = new Inventory(GameObject.FindGameObjectWithTag("inventory"), false); equipment = new Inventory(GameObject.FindGameObjectWithTag("equipS"), true); myCam = GameObject.FindGameObjectWithTag("Cam2").GetComponent <Camera> (); mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera> (); soundUI = myCam.transform.GetChild(1).GetComponent <AudioSource> (); soundEquip = myCam.transform.GetChild(2).GetComponent <AudioSource> (); playerLocation = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform> (); //playerAnim = playerLocation.GetComponent<Animator> (); //playerFollowL = GameObject.FindGameObjectWithTag ("PlayerFollow").GetComponent<Transform> (); UIInventory.SetActive(false); UINormal.SetActive(false); UIEdit.SetActive(false); UIMove.SetActive(false); UIChat.SetActive(false); UIStats.SetActive(false); UIHaS.SetActive(false); UICompass.SetActive(false); UIOptions.SetActive(false); chCam = chatCam.GetComponent <Camera> (); chCam.enabled = false; //chatCam.SetActive (false); selBox = GameObject.FindGameObjectWithTag("selectBox"); selCirc = GameObject.FindGameObjectWithTag("selectCircle"); selBox.SetActive(false); selCirc.SetActive(false); selectBox = selBox; foreach (EnemyType type in Enum.GetValues(EnemyType.archer.GetType())) { GameObject prefab = Resources.Load <GameObject>("Prefabs/enemy/" + type.ToString()); enemyPrefabs.Add(type, prefab); } }
// Use this for initialization void Start() { monologeEnd = false; _fader.alpha = 1f; if (m_instance) { DestroyImmediate(gameObject); } else { m_instance = this; DontDestroyOnLoad(gameObject); } }
public static IUIBuilder AddUICore(this IServiceCollection services, Action <IUICoreBuilder> action) { services.AddSingleton <IWindowFactory, WindowFactory>(); services.AddTransient <IWindowCommonBehavior, WindowCommonBehavior>(); services.AddSingleton <IResourceLoader, ResourceLoader>(); services.AddApplicationStageObject <LoadResourceLifecycleStageObject>(); var options = new UIOptions(); services.AddSingleton(options); var builder = new UICoreBuilder(options); action(builder); return(new UIBuilder(services, options)); }
private void AddSwaggerCommand(object sender, EventArgs e) { var project = VsHelpers.GetActiveProject(_dte); //todo: figure out if we doing CS or TS based on project type - if possible //todo: if we on a folder node, path should be folder var uiOptions = new UIOptions { Overwrite = true }; uiOptions.Target = Path.Combine(Path.GetDirectoryName(project.FullName), "api.cs"); var window = new MainWindow(); window.SetUI(uiOptions); window.ShowDialog(); }
void Start() { if (!isLocalPlayer) { DisableComponents(); AssignRemoteLayer(); } else { //Disable local graphics SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(IgnoreDrawLayerName)); //UI playerUIInstance = Instantiate(playerUIPrefab); playerUIInstance.name = playerUIPrefab.name; //Options uiOptionInstance = Instantiate(uiOptionsPrefab); uiOptionInstance.name = playerUIPrefab.name; PlayerUI playerUI = playerUIInstance.GetComponent <PlayerUI>(); UIOptions uiOptions = uiOptionInstance.GetComponent <UIOptions>(); Player player = GetComponent <Player>(); if (playerUI == null) { Debug.Log("No PlayerUI component in UI."); } else { PlayerControl pc = GetComponent <PlayerControl>(); playerUI.setPlayerController(pc); playerUI.setPlayer(player); uiOptions.setPlayerControl(pc); uiOptions.setPlayerShoot(GetComponent <PlayerShoot>()); GetComponent <PlayerControl>().uiOptions = uiOptions; } Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } GetComponent <Player>().Setup(); }
public void AuthenticateUser() { this.StartTryLogin(); Social.localUser.Authenticate(delegate(bool success) { loginSuccessful = success; if (success) { UnityEngine.Debug.Log("Successfully Authenticated"); UIOptions options = UnityEngine.Object.FindObjectOfType <UIOptions>(); if (options != null) { options.RefreshGooglePlayUI(); } this.LoginSuccess(); GPGSCloudSave.CloudSync(true); } else { UnityEngine.Debug.Log("Authentication failed"); GPGSCloudSave.syncWithCloud = true; } }); }
private void BindingUIInput() { //键盘事件 //切换分辨率 this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => SwitchResolution()), KeyCode.Enter, ModifierKeys.Alt)); //开关小地图 this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.ui.Minimap.Toggle()), KeyCode.M, ModifierKeys.None) { IsRepeatEnabled = true }); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.ui.WorldMap.Toggle()), KeyCode.W, ModifierKeys.None) { IsRepeatEnabled = true }); //选项界面 this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { var uiWnd = this.ui.Windows.OfType <UIOptions>().FirstOrDefault(); if (uiWnd == null) { uiWnd = new UIOptions(); uiWnd.DataContext = new UIOptionsDataModel(); uiWnd.OK += UIOption_OK; uiWnd.Cancel += UIOption_Cancel; uiWnd.Visible += UiWnd_Visible; uiWnd.Visibility = EmptyKeys.UserInterface.Visibility.Visible; this.ui.Windows.Add(uiWnd); uiWnd.Parent = this.ui; } else { uiWnd.Toggle(); } }), KeyCode.Escape, ModifierKeys.None)); //截图 this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { if (CanCapture()) { prepareCapture = true; } }), KeyCode.Scroll, ModifierKeys.None)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { renderEnv.Camera.AdjustRectEnabled = !renderEnv.Camera.AdjustRectEnabled; }), KeyCode.U, ModifierKeys.Control)); //层隐藏 this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.BackVisible = !this.patchVisibility.BackVisible), KeyCode.D1, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.ReactorVisible = !this.patchVisibility.ReactorVisible), KeyCode.D2, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.ObjVisible = !this.patchVisibility.ObjVisible), KeyCode.D3, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.TileVisible = !this.patchVisibility.TileVisible), KeyCode.D4, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.NpcVisible = !this.patchVisibility.NpcVisible), KeyCode.D5, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.MobVisible = !this.patchVisibility.MobVisible), KeyCode.D6, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { var visible = this.patchVisibility.FootHoldVisible; this.patchVisibility.FootHoldVisible = !visible; this.patchVisibility.LadderRopeVisible = !visible; this.patchVisibility.SkyWhaleVisible = !visible; }), KeyCode.D7, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { var portals = this.mapData.Scene.Portals; if (!this.patchVisibility.PortalVisible) { this.patchVisibility.PortalVisible = true; this.patchVisibility.PortalInEditMode = false; foreach (var item in portals) { item.View.IsEditorMode = false; } } else if (!this.patchVisibility.PortalInEditMode) { this.patchVisibility.PortalInEditMode = true; foreach (var item in portals) { item.View.IsEditorMode = true; } } else { this.patchVisibility.PortalVisible = false; } }), KeyCode.D8, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.FrontVisible = !this.patchVisibility.FrontVisible), KeyCode.D9, ModifierKeys.Control)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.BoundingBoxVisible = !this.patchVisibility.BoundingBoxVisible), KeyCode.D0, ModifierKeys.Control)); //移动操作 #region 移动操作 { //键盘移动 int boostMoveFlag = 0; var direction1 = Vector2.Zero; Action <Vector2> calcKeyboardMoveDir = dir => { if (dir.X != 0) { var preMove = dir.X * 10 * (boostMoveFlag != 0 ? 3 : 1); if (Math.Sign(preMove) * Math.Sign(direction1.X) == -1 && Math.Abs(direction1.X) <= Math.Abs(preMove)) { direction1.X = 0; } else { direction1.X += preMove; } } if (dir.Y != 0) { var preMove = dir.Y * 10 * (boostMoveFlag != 0 ? 3 : 1); if (Math.Sign(preMove) * Math.Sign(direction1.Y) == -1 && Math.Abs(direction1.Y) <= Math.Abs(preMove)) { direction1.Y = 0; } else { direction1.Y += preMove; } } }; //键盘动量减速 Action keyboardMoveSlowDown = () => { if (direction1.X > 2 || direction1.X < -2) { direction1.X *= 0.98f; } else { direction1.X = 0; } if (direction1.Y > 2 || direction1.Y < 2) { direction1.Y *= 0.98f; } else { direction1.Y = 0; } }; EmptyKeys.UserInterface.Input.KeyEventHandler keyEv; keyEv = (o, e) => { switch (e.Key) { case KeyCode.Up: calcKeyboardMoveDir(new Vector2(0, -1)); break; case KeyCode.Down: calcKeyboardMoveDir(new Vector2(0, 1)); break; case KeyCode.Left: calcKeyboardMoveDir(new Vector2(-1, 0)); break; case KeyCode.Right: calcKeyboardMoveDir(new Vector2(1, 0)); break; case KeyCode.LeftControl: boostMoveFlag |= 0x01; break; case KeyCode.RightControl: boostMoveFlag |= 0x02; break; } }; this.ui.KeyDown += keyEv; this.attachedEvent.Add(EventDisposable(keyEv, _ev => this.ui.KeyDown -= _ev)); keyEv = (o, e) => { switch (e.Key) { case KeyCode.LeftControl: boostMoveFlag &= ~0x01; break; case KeyCode.RightControl: boostMoveFlag &= ~0x02; break; } }; this.ui.PreviewKeyUp += keyEv; this.attachedEvent.Add(EventDisposable(keyEv, _ev => this.ui.PreviewKeyUp -= _ev)); //鼠标移动 bool isMouseDown = false; var direction2 = Vector2.Zero; Action <EmptyKeys.UserInterface.Input.MouseEventArgs> calcMouseMoveDir = e => { var mousePos = e.GetPosition(); Vector2 vec = new Vector2(2 * mousePos.X / this.ui.Width - 1, 2 * mousePos.Y / this.ui.Height - 1); var distance = vec.Length(); if (distance >= 0.4f) { vec *= (distance - 0.4f) / distance; } else { vec = Vector2.Zero; } direction2 = vec * 20; }; EmptyKeys.UserInterface.Input.MouseEventHandler mouseEv; EmptyKeys.UserInterface.Input.MouseButtonEventHandler mouseBtnEv; mouseBtnEv = (o, e) => { if (e.ChangedButton == EmptyKeys.UserInterface.Input.MouseButton.Right) { isMouseDown = true; calcMouseMoveDir(e); } }; this.ui.MouseDown += mouseBtnEv; this.attachedEvent.Add(EventDisposable(mouseBtnEv, _ev => this.ui.MouseDown -= _ev)); mouseEv = (o, e) => { if (isMouseDown) { calcMouseMoveDir(e); } }; this.ui.MouseMove += mouseEv; this.attachedEvent.Add(EventDisposable(mouseEv, _ev => this.ui.MouseMove -= _ev)); mouseBtnEv = (o, e) => { if (e.ChangedButton == EmptyKeys.UserInterface.Input.MouseButton.Right) { isMouseDown = false; direction2 = Vector2.Zero; } }; this.ui.MouseUp += mouseBtnEv; this.attachedEvent.Add(EventDisposable(mouseBtnEv, _ev => this.ui.MouseUp -= _ev)); //更新事件 EventHandler ev = (o, e) => { this.renderEnv.Camera.Center += direction1 + direction2 * ((boostMoveFlag != 0) ? 3 : 1); keyboardMoveSlowDown(); }; this.ui.InputUpdated += ev; this.attachedEvent.Add(EventDisposable(ev, _ev => this.ui.InputUpdated -= _ev)); } #endregion //点击事件 var disposable = UIHelper.RegisterClickEvent <SceneItem>(this.ui.ContentControl, (sender, point) => { int x = (int)point.X; int y = (int)point.Y; var mouseTarget = this.allItems.Reverse <ItemRect>().FirstOrDefault(item => { return(item.rect.Contains(x, y) && (item.item is PortalItem || item.item is ReactorItem)); }); return(mouseTarget.item); }, this.OnSceneItemClick); this.attachedEvent.Add(disposable); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { if (this.ui.Visibility == Visibility.Visible) { this.ui.ChatBox.TextBoxChat.Focus(); } }), KeyCode.Enter, ModifierKeys.None)); this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.ui.ChatBox.Toggle()), KeyCode.Oem3, ModifierKeys.None)); this.ui.WorldMap.MapSpotClick += WorldMap_MapSpotClick; this.ui.ChatBox.TextBoxChat.TextSubmit += ChatBox_TextSubmit; }
private static UIBase ParseAttributeForOptionsField(IElement element, int[] layout) { int[] elmLayout = GetLayout(element.Children[0].Style, layout); var tmp = new UIOptions() { x = elmLayout[0], y = elmLayout[1], width = elmLayout[2], height = elmLayout[3] }; try { if (element.Children[0].TextContent[0] != '~') { // Is readonly attribute tmp.Text = element.Children[0].TextContent; tmp.ReadOnly = true; } else { tmp.Text = element.Children[0].TextContent.Substring(1); } tmp.WidthLabel = element.Children[0].GetWidth(); tmp.NestedName = element.Children[1].GetAttribute("nested-name"); tmp.Value = element.Children[1].GetAttribute("value"); tmp.Options = new Dictionary <string, string>(); tmp.Options.Add("", ""); foreach (var elm in element.Children[1].Children) { if (elm.TagName == "OPTION") { // Get the value of the selection (id) string value = elm.GetAttribute("value"); // Get the description of the option string key = elm.TextContent.Replace('\u00A0', ' '); /// Make sur no break spaces are replaced by spaces. // This can be used to lookup the comos value to change in case user select a description (key) tmp.Options[key] = value; // !! comos web could have duplicate optons, assuming here values will be same. string selected = elm.GetAttribute("selected"); if (selected != null && string.Compare(selected, "selected") == 0) { // We assume here that when a comos spec has a unit. The selection of the unit // Is the last xhtml eleemnt of the spec. tmp.Value = key; } } else { Debug.Assert(false); } } if (tmp.Value == null) { tmp.Value = " "; } } catch (Exception) { //throw; } return(tmp); }
public UIBuilder(IServiceCollection services, UIOptions options) { Services = services; this.options = options; }
public void OnCollisionEnter2D(Collision2D collision) { UIOptions.ChangeScene("Anger"); }
public LoadResourceLifecycleStageObject(IResourceLoader loader, UIOptions options) { _loader = loader; _options = options; }
private static void Postfix(ref UIScreenOptions __instance) { // Add a tab to the settings int optionsCount = (int)m_OptionsTypeCount.GetValue(__instance) + 1; m_OptionsTypeCount.SetValue(__instance, optionsCount); // Get settings tabs to an array Toggle[] optionsTabs = new Toggle[optionsCount]; ((Toggle[])m_OptionsTabs.GetValue(__instance)).CopyTo(optionsTabs, 0); // Copy last tab to new tab Toggle modsToggle = GameObject.Instantiate <Toggle>(optionsTabs[optionsCount - 2]); modsToggle.transform.SetParent(optionsTabs[optionsCount - 2].transform.parent, false); modsToggle.gameObject.SetActive(true); // Clear and assign name GameObject.DestroyImmediate(modsToggle.gameObject.GetComponentInChildren <UILocalisedText>()); modsToggle.GetComponentInChildren <Text>().text = "MODS"; optionsTabs[optionsCount - 1] = modsToggle; // Move tabs var x = 0f; foreach (var toggle in optionsTabs) { if (!toggle) { continue; } RectTransform toggleRect = toggle.GetComponent <RectTransform>(); if (toggleRect) { Vector2 anchorMin = toggleRect.anchorMin; anchorMin.x = x; toggleRect.anchorMin = anchorMin; x += 0.2f; Vector2 anchorMax = toggleRect.anchorMax; anchorMax.x = x; toggleRect.anchorMax = anchorMax; } } // Get the tab panels to an array UIOptions[] optionsElements = new UIOptions[optionsCount]; ((UIOptions[])m_OptionsElements.GetValue(__instance)).CopyTo(optionsElements, 0); // Give new tab a UIOptions panel and position to reference DefaultControls.Resources resources = default(DefaultControls.Resources); GameObject Mods = DefaultControls.CreatePanel(resources); Mods.name = "Mods"; GameObject.DestroyImmediate(Mods.GetComponent <Image>()); RectTransform panel_rect = Mods.GetComponent <RectTransform>(); RectTransform reference_rect = optionsElements[0].gameObject.GetComponent <RectTransform>(); panel_rect.anchoredPosition3D = reference_rect.anchoredPosition3D; panel_rect.anchorMin = reference_rect.anchorMin; panel_rect.anchorMax = reference_rect.anchorMax; panel_rect.pivot = reference_rect.pivot; panel_rect.sizeDelta = reference_rect.sizeDelta; optionsElements[optionsCount - 1] = Mods.AddComponent <UIOptionsMods>(); Mods.transform.SetParent(optionsElements[0].gameObject.transform.parent, false); // Allow tab to be activatable var instance = __instance; modsToggle.onValueChanged.AddListener(delegate(bool set) { if (set) { instance.ShowOptions((UIScreenOptions.OptionsType)(optionsCount - 1)); } }); ((UIOptionsMods)optionsElements[optionsCount - 1]).tab_toggle = modsToggle; // Create UI elements GameObject bottom_panel = DefaultControls.CreatePanel(resources); bottom_panel.name = "Bottom Panel"; GameObject.DestroyImmediate(bottom_panel.GetComponent <Image>()); var bottomRect = bottom_panel.GetComponent <RectTransform>(); bottomRect.anchoredPosition3D = new Vector3(0, -289.6f, 0); bottomRect.anchorMin = Vector2.zero; bottomRect.anchorMax = Vector2.one; bottomRect.pivot = Vector2.one * 0.5f; bottomRect.sizeDelta = new Vector2(-60f, -579.2f); var bottomGroup = bottom_panel.AddComponent <GridLayoutGroup>(); bottomGroup.childAlignment = TextAnchor.MiddleLeft; bottomGroup.padding = new RectOffset(0, 0, 0, 0); bottomGroup.cellSize = new Vector2(536f, 40f); bottomGroup.constraint = GridLayoutGroup.Constraint.Flexible; //bottomGroup.constraintCount = 2; bottomGroup.spacing = new Vector2(60f, 15f); bottomGroup.startAxis = GridLayoutGroup.Axis.Vertical; bottomGroup.startCorner = GridLayoutGroup.Corner.UpperLeft; bottom_panel.transform.SetParent(Mods.transform, false); GameObject page_info = DefaultControls.CreateText(resources); var page_infoRect = page_info.GetComponent <RectTransform>(); page_infoRect.anchoredPosition3D = new Vector3(268f, -25.3f, 0); page_infoRect.anchorMin = Vector2.up; page_infoRect.anchorMax = Vector2.up; page_infoRect.offsetMin = new Vector2(0, -45.3f); page_infoRect.offsetMax = new Vector2(536f, -5.3f); page_infoRect.pivot = Vector2.one * 0.5f; //page_infoRect.sizeDelta(536.0, 40.0) Text text = page_info.GetComponent <Text>(); text.text = ""; text.font = UIElements.ExoSemiBold; text.fontSize = 25; text.color = Color.white; page_info.transform.SetParent(bottom_panel.transform, false); GameObject buttons_panel = DefaultControls.CreatePanel(resources); buttons_panel.name = "Page Panel"; GameObject.DestroyImmediate(buttons_panel.GetComponent <Image>()); var button_group = buttons_panel.AddComponent <HorizontalLayoutGroup>(); button_group.childAlignment = TextAnchor.MiddleRight; button_group.childControlWidth = false; button_group.childControlHeight = true; button_group.childForceExpandWidth = false; button_group.childForceExpandHeight = true; button_group.spacing = 0; button_group.padding = new RectOffset(0, 0, 0, 0); buttons_panel.transform.SetParent(bottom_panel.transform, false); GameObject prev_page = GameObject.Instantiate(UIElements.Button_Back); prev_page.SetActive(true); GameObject.DestroyImmediate(prev_page.GetComponent <UIButtonGoBack>()); var prevRect = prev_page.GetComponent <RectTransform>(); prevRect.anchoredPosition3D = Vector3.zero; prev_page.GetComponent <Button>().onClick.RemoveAllListeners(); var prevState = prev_page.GetComponent <Button>().spriteState; prevState.disabledSprite = UIElements.Button_Disabled_BG; prev_page.GetComponent <Button>().spriteState = prevState; prev_page.transform.SetParent(buttons_panel.transform, false); GameObject next_page = GameObject.Instantiate(UIElements.Button_Back); next_page.SetActive(true); GameObject.DestroyImmediate(next_page.GetComponent <UIButtonGoBack>()); var nextRect = next_page.GetComponent <RectTransform>(); nextRect.anchoredPosition3D = Vector3.zero; next_page.GetComponent <Button>().onClick.RemoveAllListeners(); var nextState = next_page.GetComponent <Button>().spriteState; nextState.disabledSprite = UIElements.Button_Disabled_BG; next_page.GetComponent <Button>().spriteState = nextState; var next_iconRect = next_page.transform.Find("Icon").GetComponent <RectTransform>(); next_iconRect.localEulerAngles = new Vector3(0, 180f, 0); next_page.transform.SetParent(buttons_panel.transform, false); UIOptionsMods.PageInfo = page_info; UIOptionsMods.PrevPage = prev_page; UIOptionsMods.NextPage = next_page; GameObject top_panel = DefaultControls.CreatePanel(resources); top_panel.name = "Top Panel"; GameObject.DestroyImmediate(top_panel.GetComponent <Image>()); var topRect = top_panel.GetComponent <RectTransform>(); topRect.anchoredPosition3D = new Vector3(0, 285f, 0); topRect.anchorMin = Vector2.zero; topRect.anchorMax = Vector2.one; topRect.pivot = Vector2.one * 0.5f; topRect.sizeDelta = new Vector2(-6.3f, -569.0f); var group = top_panel.AddComponent <HorizontalLayoutGroup>(); group.childAlignment = TextAnchor.MiddleCenter; group.childControlWidth = true; group.childControlHeight = true; group.childForceExpandWidth = true; group.childForceExpandHeight = true; group.spacing = 0; group.padding = new RectOffset(0, 0, 0, 0); top_panel.transform.SetParent(Mods.transform, false); GameObject category1 = DefaultControls.CreatePanel(resources); category1.name = "Category 1"; GameObject.DestroyImmediate(category1.GetComponent <Image>()); category1.transform.SetParent(top_panel.transform, false); GameObject category1_title = DefaultControls.CreateText(resources); category1_title.name = "Title"; var title1 = category1_title.GetComponent <Text>(); title1.text = "LEFT SIDE"; title1.alignment = TextAnchor.MiddleCenter; title1.font = UIElements.ExoSemiBold; title1.fontSize = 16; title1.color = Color.white; var title1Rect = category1_title.GetComponent <RectTransform>(); title1Rect.anchoredPosition3D = new Vector3(0, -2.1f, 0); title1Rect.pivot = title1Rect.anchorMin = title1Rect.anchorMax = Vector2.one * 0.5f; title1Rect.sizeDelta = new Vector2(160f, 55.6f); var title1Shadow = category1_title.AddComponent <Shadow>(); title1Shadow.effectColor = new Color(0, 0, 0, 0.5f); title1Shadow.effectDistance = new Vector2(1f, -1f); category1_title.transform.SetParent(category1.transform, false); GameObject category2 = DefaultControls.CreatePanel(resources); category2.name = "Category 2"; GameObject.DestroyImmediate(category2.GetComponent <Image>()); category2.transform.SetParent(top_panel.transform, false); GameObject category2_title = DefaultControls.CreateText(resources); category2_title.name = "Title"; var title2 = category2_title.GetComponent <Text>(); title2.text = "RIGHT SIDE"; title2.alignment = TextAnchor.MiddleCenter; title2.font = UIElements.ExoSemiBold; title2.fontSize = 16; title2.color = Color.white; var title2Rect = category2_title.GetComponent <RectTransform>(); title2Rect.anchoredPosition3D = new Vector3(0, -2.1f, 0); title2Rect.pivot = title2Rect.anchorMin = title2Rect.anchorMax = Vector2.one * 0.5f; title2Rect.sizeDelta = new Vector2(160f, 55.6f); var title2Shadow = category2_title.AddComponent <Shadow>(); title2Shadow.effectColor = new Color(0, 0, 0, 0.5f); title2Shadow.effectDistance = new Vector2(1f, -1f); category2_title.transform.SetParent(category2.transform, false); GameObject mid_panel = DefaultControls.CreatePanel(resources); mid_panel.name = "Mid Panel"; var midImage = mid_panel.GetComponent <Image>(); midImage.sprite = UIElements.Option_BG; midImage.type = Image.Type.Simple; midImage.color = Color.white; var midRect = mid_panel.GetComponent <RectTransform>(); midRect.anchoredPosition3D = new Vector3(0, -4.1f, 0); midRect.anchorMin = Vector2.zero; midRect.anchorMax = Vector2.one; midRect.offsetMin = new Vector2(3.2f, 50.7f); midRect.offsetMax = new Vector2(-3.2f, -59.0f); midRect.pivot = Vector2.one * 0.5f; var midGroup = mid_panel.AddComponent <HorizontalLayoutGroup>(); midGroup.childAlignment = TextAnchor.UpperLeft; midGroup.childControlWidth = true; midGroup.childControlHeight = true; midGroup.childForceExpandWidth = true; midGroup.childForceExpandHeight = true; midGroup.spacing = 2f; midGroup.padding = new RectOffset(2, 2, 2, 2); mid_panel.transform.SetParent(Mods.transform, false); GameObject content1 = DefaultControls.CreatePanel(resources); content1.name = "Content 1"; var content1Image = content1.GetComponent <Image>(); content1Image.sprite = UIElements.Option_Content_BG; content1Image.type = Image.Type.Simple; content1Image.color = Color.white; var content1Group = content1.AddComponent <VerticalLayoutGroup>(); content1Group.childAlignment = TextAnchor.UpperCenter; content1Group.childControlWidth = true; content1Group.childControlHeight = true; content1Group.childForceExpandWidth = true; content1Group.childForceExpandHeight = false; content1Group.spacing = 2f; content1Group.padding = new RectOffset(0, 0, 5, 0); content1.transform.SetParent(mid_panel.transform, false); GameObject content2 = DefaultControls.CreatePanel(resources); content2.name = "Content 2"; var content2Image = content2.GetComponent <Image>(); content2Image.sprite = UIElements.Option_Content_BG; content2Image.type = Image.Type.Simple; content2Image.color = Color.white; var content2Group = content2.AddComponent <VerticalLayoutGroup>(); content2Group.childAlignment = TextAnchor.UpperCenter; content2Group.childControlWidth = true; content2Group.childControlHeight = true; content2Group.childForceExpandWidth = true; content2Group.childForceExpandHeight = false; content2Group.spacing = 2f; content2Group.padding = new RectOffset(0, 0, 5, 0); content2.transform.SetParent(mid_panel.transform, false); UIOptionsMods.MidPanel = mid_panel; UIOptionsMods.Content1 = content1; UIOptionsMods.Content2 = content2; midGroup.CalculateLayoutInputHorizontal(); midGroup.CalculateLayoutInputVertical(); midGroup.SetLayoutHorizontal(); midGroup.SetLayoutVertical(); content2Group.CalculateLayoutInputHorizontal(); content2Group.CalculateLayoutInputVertical(); content2Group.SetLayoutHorizontal(); content2Group.SetLayoutVertical(); content1Group.CalculateLayoutInputHorizontal(); content1Group.CalculateLayoutInputVertical(); content1Group.SetLayoutHorizontal(); content1Group.SetLayoutVertical(); // Push the new tab to the arrays m_OptionsTabs.SetValue(__instance, optionsTabs); m_OptionsElements.SetValue(__instance, optionsElements); }
public UICoreBuilder(UIOptions options) => _options = options;