void CreateView() { ModDebug.Log("Creating view"); GameObject rootObject = new GameObject(panelName); tabstrip = rootObject.AddComponent <UITabstrip>(); CreateButtons(); roadsOptionPanel.AttachUIComponent(tabstrip.gameObject); tabstrip.relativePosition = new Vector3(90, 38); tabstrip.width = 80; tabstrip.selectedIndex = -1; tabstrip.padding = new RectOffset(0, 1, 0, 0); if (builtinModeChangedHandler == null) { builtinModeChangedHandler = (UIComponent component, int index) => { if (!ignoreBuiltinTabstripEvents) { if (selectedToolModeChanged != null) { selectedToolModeChanged(ToolMode.None); } } }; } builtinTabstrip.eventSelectedIndexChanged += builtinModeChangedHandler; // Setting selectedIndex needs to be delayed for some reason tabstrip.StartCoroutine(FinishCreatingView()); }
void CreateView() { ModDebug.Log("Creating view"); GameObject rootObject = new GameObject("ExtendedRoadUpgradePanel"); tabstrip = rootObject.AddComponent <UITabstrip>(); UIButton tabTemplate = (UIButton)builtinTabstrip.tabs[0]; int spriteWidth = 31; int spriteHeight = 31; string[] spriteNames = { "ERUButtonBg", "ERUButtonBgPressed", "ERUButtonBgHovered", "ERUIconTwoway", "ERUIconTwowayPressed", "ERUIconOneway", "ERUIconOnewayPressed" }; UITextureAtlas atlas = CreateTextureAtlas("sprites.png", "ExtendedRoadUpgradeUI", tabTemplate.atlas.material, spriteWidth, spriteHeight, spriteNames); List <UIButton> tabs = new List <UIButton>(); tabs.Add(tabstrip.AddTab("", null, false)); tabs.Add(tabstrip.AddTab("", null, false)); foreach (UIButton tab in tabs) { tab.name = "ExtendedRoadUpgradeButton"; tab.atlas = atlas; tab.size = new Vector2(spriteWidth, spriteHeight); tab.normalBgSprite = "ERUButtonBg"; tab.disabledBgSprite = "ERUButtonBg"; tab.hoveredBgSprite = "ERUButtonBgHovered"; tab.pressedBgSprite = "ERUButtonBgPressed"; tab.focusedBgSprite = "ERUButtonBgPressed"; tab.playAudioEvents = true; } tabs[0].name = "ExtendedRoadUpgradeButtonTwoWay"; tabs[0].tooltip = "Upgrade To Two-Way Road"; tabs[0].normalFgSprite = tabs[0].disabledFgSprite = tabs[0].hoveredFgSprite = "ERUIconTwoway"; tabs[0].pressedFgSprite = tabs[0].focusedFgSprite = "ERUIconTwowayPressed"; tabs[1].name = "ExtendedRoadUpgradeButtonOneWay"; tabs[1].tooltip = "Upgrade To One-Way Road"; tabs[1].normalFgSprite = tabs[1].disabledFgSprite = tabs[1].hoveredFgSprite = "ERUIconOneway"; tabs[1].pressedFgSprite = tabs[1].focusedFgSprite = "ERUIconOnewayPressed"; roadsOptionPanel.AttachUIComponent(tabstrip.gameObject); tabstrip.relativePosition = new Vector3(169, 38); tabstrip.width = 80; tabstrip.selectedIndex = -1; tabstrip.padding = new RectOffset(0, 1, 0, 0); if (builtinModeChangedHandler == null) { builtinModeChangedHandler = (UIComponent component, int index) => { ModDebug.Log(string.Format("Builtin mode changed to: {0}, ignore: {1}", index, ignoreBuiltinTabstripEvents)); if (!ignoreBuiltinTabstripEvents) { if (selectedToolModeChanged != null) { selectedToolModeChanged(ToolMode.None); } } }; } builtinTabstrip.eventSelectedIndexChanged += builtinModeChangedHandler; // Setting selectedIndex needs to be delayed for some reason tabstrip.StartCoroutine(FinishCreatingView()); }
void CreateView() { ModDebug.Log("Creating view"); GameObject rootObject = new GameObject(panelName); tabstrip = rootObject.AddComponent<UITabstrip>(); CreateButtons(); roadsOptionPanel.AttachUIComponent(tabstrip.gameObject); tabstrip.relativePosition = new Vector3(90, 38); tabstrip.width = 80; tabstrip.selectedIndex = -1; tabstrip.padding = new RectOffset(0, 1, 0, 0); if (builtinModeChangedHandler == null) { builtinModeChangedHandler = (UIComponent component, int index) => { if (!ignoreBuiltinTabstripEvents) { if (selectedToolModeChanged != null) selectedToolModeChanged(ToolMode.None); } }; } builtinTabstrip.eventSelectedIndexChanged += builtinModeChangedHandler; // Setting selectedIndex needs to be delayed for some reason tabstrip.StartCoroutine(FinishCreatingView()); }
void CreateView() { ModDebug.Log("Creating view"); GameObject rootObject = new GameObject("ExtendedRoadUpgradePanel"); tabstrip = rootObject.AddComponent<UITabstrip>(); UIButton tabTemplate = (UIButton)builtinTabstrip.tabs[0]; int spriteWidth = 31; int spriteHeight = 31; string[] spriteNames = { "ERUButtonBg", "ERUButtonBgPressed", "ERUButtonBgHovered", "ERUIconTwoway", "ERUIconTwowayPressed", "ERUIconOneway", "ERUIconOnewayPressed" }; UITextureAtlas atlas = CreateTextureAtlas("sprites.png", "ExtendedRoadUpgradeUI", tabTemplate.atlas.material, spriteWidth, spriteHeight, spriteNames); List<UIButton> tabs = new List<UIButton>(); tabs.Add(tabstrip.AddTab("", null, false)); tabs.Add(tabstrip.AddTab("", null, false)); foreach (UIButton tab in tabs) { tab.name = "ExtendedRoadUpgradeButton"; tab.atlas = atlas; tab.size = new Vector2(spriteWidth, spriteHeight); tab.normalBgSprite = "ERUButtonBg"; tab.disabledBgSprite = "ERUButtonBg"; tab.hoveredBgSprite = "ERUButtonBgHovered"; tab.pressedBgSprite = "ERUButtonBgPressed"; tab.focusedBgSprite = "ERUButtonBgPressed"; tab.playAudioEvents = true; } tabs[0].name = "ExtendedRoadUpgradeButtonTwoWay"; tabs[0].tooltip = "Upgrade To Two-Way Road"; tabs[0].normalFgSprite = tabs[0].disabledFgSprite = tabs[0].hoveredFgSprite = "ERUIconTwoway"; tabs[0].pressedFgSprite = tabs[0].focusedFgSprite = "ERUIconTwowayPressed"; tabs[1].name = "ExtendedRoadUpgradeButtonOneWay"; tabs[1].tooltip = "Upgrade To One-Way Road"; tabs[1].normalFgSprite = tabs[1].disabledFgSprite = tabs[1].hoveredFgSprite = "ERUIconOneway"; tabs[1].pressedFgSprite = tabs[1].focusedFgSprite = "ERUIconOnewayPressed"; roadsOptionPanel.AttachUIComponent(tabstrip.gameObject); tabstrip.relativePosition = new Vector3(169, 38); tabstrip.width = 80; tabstrip.selectedIndex = -1; tabstrip.padding = new RectOffset(0, 1, 0, 0); if (builtinModeChangedHandler == null) { builtinModeChangedHandler = (UIComponent component, int index) => { if (!ignoreBuiltinTabstripEvents) { if (selectedToolModeChanged != null) selectedToolModeChanged(ToolMode.None); } }; } builtinTabstrip.eventSelectedIndexChanged += builtinModeChangedHandler; // Setting selectedIndex needs to be delayed for some reason tabstrip.StartCoroutine(FinishCreatingView()); }