public override void OnSelectionChanged(UISelectButton button, string option) { this.m_OptionsChanged = true; if (option == "Yes") { this.m_InvertMouseY = true; } else if (option == "No") { this.m_InvertMouseY = false; } }
public virtual void AddSelectButton(UISelectButton select) { if (select == null) { return; } if (select.m_LeftArrow == null || select.m_RightArrow == null) { return; } Transform transform = select.transform.FindDeepChild("Title"); if (!transform) { DebugUtils.Assert(transform, "Slider object is missing 'Title'!", true, DebugUtils.AssertType.Info); return; } Transform transform2 = select.transform.FindDeepChild("Text"); if (!transform2) { DebugUtils.Assert(transform2, "Slider object is missing 'Text' option field!", true, DebugUtils.AssertType.Info); return; } if (!this.m_OptionsObjects.Values.Any((MenuBase.MenuOptionData d) => d.m_SelectButton == select)) { Text componentInChildren = transform.GetComponentInChildren <Text>(); Text componentInChildren2 = transform2.GetComponentInChildren <Text>(); RectTransform rectTransform = select.GetComponent <RectTransform>() ?? transform.GetComponent <RectTransform>(); this.m_OptionsObjects.Add(select.transform.gameObject, new MenuBase.MenuOptionData { m_SelectButton = select, m_Object = select.gameObject, m_Texts = new Text[] { componentInChildren, componentInChildren2 }, m_ExtentRectTransforms = new RectTransform[] { rectTransform, componentInChildren2.GetComponent <RectTransform>(), select.m_LeftArrow.GetComponent <RectTransform>(), select.m_RightArrow.GetComponent <RectTransform>() }, m_InteractRectTransforms = new RectTransform[] { select.m_LeftArrow.GetComponent <RectTransform>(), select.m_RightArrow.GetComponent <RectTransform>() } }); } }
public override void OnSelectionChanged(UISelectButton button, string option) { if (option == "Yes") { this.m_InvertMouseY = true; } else if (option == "No") { this.m_InvertMouseY = false; } this.m_AcceptButton.interactable = true; }
public void StartAnimation(int index) { UIAnimations animation = (UIAnimations)m_animations[index]; for (int i = 0; i < animation.control_data.Count; ++i) { UIAnimations.ControlData data = (UIAnimations.ControlData)animation.control_data[i]; int control_id = data.control_id; string type = m_control_table[control_id].GetType().ToString(); if ("UIClickButton" == type) { UIClickButton button = ((UIClickButton)m_control_table[control_id]); data.pos.x = button.Rect.x; data.pos.y = button.Rect.y; data.angle = button.GetRotate(); } else if ("UIPushButton" == type) { UIPushButton button = ((UIPushButton)m_control_table[control_id]); data.pos.x = button.Rect.x; data.pos.y = button.Rect.y; data.angle = button.GetRotate(); } else if ("UISelectButton" == type) { UISelectButton button = ((UISelectButton)m_control_table[control_id]); data.pos.x = button.Rect.x; data.pos.y = button.Rect.y; data.angle = button.GetRotate(); } else if ("UIImage" == type) { UIImage image = ((UIImage)m_control_table[control_id]); data.pos.x = image.Rect.x; data.pos.y = image.Rect.y; data.angle = image.GetRotation(); } else if ("UIText" == type) { UIText text = ((UIText)m_control_table[control_id]); data.pos.x = text.Rect.x; data.pos.y = text.Rect.y; } } animation.Reset(); animation.Start(); //动作开始前存储当前该动作控件的初始数据 }
public override void OnSelectionChanged(UISelectButton button, string option) { if (button == this.m_InvertMouseYButton) { if (option == "Yes") { this.m_InvertMouseY = true; return; } if (option == "No") { this.m_InvertMouseY = false; } } }
public override void OnSelectionChanged(UISelectButton button, string option) { if (this.m_SearchSessionVisibility == button) { this.m_WantedVisibility = this.m_SearchSessionVisibility.GetSelectedOptionEnumValue <P2PGameVisibility>(); this.OnRefresh(); return; } if (this.m_HostedSessionVisibility == button) { P2PGameVisibility selectedOptionEnumValue = this.m_HostedSessionVisibility.GetSelectedOptionEnumValue <P2PGameVisibility>(); GreenHellGame.Instance.m_Settings.m_GameVisibility = selectedOptionEnumValue; this.UpdateStatusText(); return; } base.OnSelectionChanged(button, option); }
protected virtual void Awake() { if (this.m_AutoFindButtons) { Transform transform = base.transform; if (transform) { List <GameObject> list = new List <GameObject>(); foreach (RectTransform rectTransform in General.GetComponentsDeepChild <RectTransform>(transform.gameObject)) { if (rectTransform.GetComponent <Button>() || rectTransform.GetComponent <UISliderEx>() || rectTransform.GetComponent <UISelectButton>()) { list.Add(rectTransform.gameObject); } } foreach (GameObject gameObject in list) { Button component = gameObject.GetComponent <Button>(); if (component) { this.AddMenuButton(component, null); } else { UISliderEx component2 = gameObject.GetComponent <UISliderEx>(); if (component2) { this.AddMenuSlider(component2); } else { UISelectButton component3 = gameObject.GetComponent <UISelectButton>(); if (component3) { this.AddSelectButton(component3); } } } } } } this.m_ChangeableOptions = base.GetComponentsInChildren <IUIChangeableOption>(); }
public override void OnSelectionChanged(UISelectButton button, string option) { if (button == this.m_Resolution || button == this.m_Fullscreen) { Resolution current_res = ResolutionExtension.ResolutionFromString(ResolutionExtension.ToString(this.m_Resolution.GetSelectedOption(), this.m_RefreshRate.GetSelectedOption())); this.FillAvailableRefreshRate(current_res); return; } if (button == this.m_Quality) { Streamer[] array = Resources.FindObjectsOfTypeAll <Streamer>(); for (int i = 0; i < array.Length; i++) { if (array[i] != null) { array[i].SetQualitySettingsRanges(button.m_SelectionIdx); } } } }
private void UpdateButton(UISelectButton button) { RectTransform component = button.GetComponent <RectTransform>(); if (RectTransformUtility.RectangleContainsScreenPoint(component, Input.mousePosition)) { this.m_ActiveButton = button.gameObject; } component = button.m_Title.GetComponent <RectTransform>(); Vector3 localPosition = component.localPosition; float num = (!(this.m_ActiveButton == button.gameObject)) ? this.m_ButtonTextStartX : this.m_SelectedButtonX; float num2 = Mathf.Ceil(num - localPosition.x) * Time.unscaledDeltaTime * 10f; localPosition.x += num2; component.localPosition = localPosition; if (this.m_ActiveButton == button.gameObject) { Color color = button.GetColor(); color.a = 1f; button.SetColor(color); } }
public UpgradePanel(Rect rect, int index) { arenaMaterial = UIResourceMgr.GetInstance().GetMaterial("ArenaMenu"); selectPanelButton = new UISelectButton(); selectPanelButton.SetTexture(UIButtonBase.State.Normal, arenaMaterial, ArenaMenuTexturePosition.UpgradeButtonNormal, AutoRect.AutoSize(ArenaMenuTexturePosition.UpgradeButtonNormal)); selectPanelButton.SetTexture(UIButtonBase.State.Pressed, arenaMaterial, ArenaMenuTexturePosition.UpgradeButtonPressed, AutoRect.AutoSize(ArenaMenuTexturePosition.UpgradeButtonPressed)); selectPanelButton.SetTexture(UIButtonBase.State.Disabled, arenaMaterial, ArenaMenuTexturePosition.UpgradeButtonNormal, AutoRect.AutoSize(ArenaMenuTexturePosition.UpgradeButtonNormal)); selectPanelButton.Rect = AutoRect.AutoPos(rect); arrowImage = new UIImage(); arrowImage.SetTexture(arenaMaterial, ArenaMenuTexturePosition.Arrow, AutoRect.AutoSize(ArenaMenuTexturePosition.Arrow)); arrowImage.Rect = AutoRect.AutoPos(new Rect(rect.x + 276, rect.y + 62, 36, 26)); Material buttonsMaterial = UIResourceMgr.GetInstance().GetMaterial("Buttons"); bulletLogo = new UIImage(); Rect brect = ButtonsTexturePosition.GetBulletsLogoRect(1); bulletLogo.SetTexture(buttonsMaterial, brect, AutoRect.AutoSize(brect)); bulletLogo.Rect = AutoRect.AutoPos(new Rect(rect.x + 156, rect.y + 46, 44, 52)); bulletLogo.Visible = false; bulletLogo.Enable = false; buttonText = new UIText(); buttonText.Set(ConstData.FONT_NAME2, "", ColorName.fontColor_orange); buttonText.Rect = AutoRect.AutoPos(new Rect(rect.x + 56, rect.y + 25, 175, 68)); currentValueText = new UIText(); currentValueText.Set(ConstData.FONT_NAME2, "", ColorName.fontColor_orange); currentValueText.Rect = AutoRect.AutoPos(new Rect(688, 526 - 100 * index, 92, 32)); currentValueText.AlignStyle = UIText.enAlignStyle.right; nextValueText = new UIText(); nextValueText.Set(ConstData.FONT_NAME2, "", ColorName.fontColor_orange); nextValueText.Rect = AutoRect.AutoPos(new Rect(810, 526 - 100 * index, 92, 32)); nextValueText.AlignStyle = UIText.enAlignStyle.left; for (int i = 0; i < 10; i++) { starsBackground[i] = new UIImage(); starsBackground[i].SetTexture(arenaMaterial, ArenaMenuTexturePosition.StarEmpty, AutoRect.AutoSize(ArenaMenuTexturePosition.StarEmpty)); stars[i] = new UIImage(); stars[i].SetTexture(arenaMaterial, ArenaMenuTexturePosition.StarFull, AutoRect.AutoSize(ArenaMenuTexturePosition.StarFull)); int x = 572 + i * 24; int y = 490 - index * 100; starsBackground[i].Rect = AutoRect.AutoPos(new Rect(x, y, 24, 22)); starsBackground[i].Enable = false; stars[i].Rect = AutoRect.AutoPos(new Rect(x, y, 24, 22)); stars[i].Enable = false; } Add(selectPanelButton); Add(arrowImage); Add(bulletLogo); Add(buttonText); Add(currentValueText); Add(nextValueText); for (int i = 0; i < 10; i++) { Add(starsBackground[i]); } for (int i = 0; i < 10; i++) { Add(stars[i]); } }
public void Update() { foreach (UIAnimations animation in m_animations.Values) { if (!animation.IsRuning()) { continue; } animation.Update(Time.deltaTime); bool have_translate = false; Vector2 translate_pos = new Vector2(0, 0); if (animation.IsTranslating()) { translate_pos = animation.GetTranslate(); have_translate = true; } bool have_rotate = false; float rotate_delta = 0; if (animation.IsRotating()) { rotate_delta = animation.GetRotate(); have_rotate = true; } for (int i = 0; i < animation.control_data.Count; ++i) { UIAnimations.ControlData data = (UIAnimations.ControlData)animation.control_data[i]; int control_id = data.control_id; string type = m_control_table[control_id].GetType().ToString(); if ("UIClickButton" == type) { UIClickButton button = ((UIClickButton)m_control_table[control_id]); if (have_translate) { button.Rect = new Rect(translate_pos.x + data.pos.x, translate_pos.y + data.pos.y, button.Rect.width, button.Rect.height); } if (have_rotate) { button.SetRotate(rotate_delta); } } else if ("UIPushButton" == type) { UIPushButton button = ((UIPushButton)m_control_table[control_id]); if (have_translate) { button.Rect = new Rect(translate_pos.x, translate_pos.y, button.Rect.width, button.Rect.height); } if (have_rotate) { button.SetRotate(rotate_delta); } } else if ("UISelectButton" == type) { UISelectButton button = ((UISelectButton)m_control_table[control_id]); if (have_translate) { button.Rect = new Rect(translate_pos.x, translate_pos.y, button.Rect.width, button.Rect.height); } if (have_rotate) { button.SetRotate(rotate_delta); } } else if ("UIImage" == type) { UIImage image = ((UIImage)m_control_table[control_id]); if (have_translate) { image.Rect = new Rect(translate_pos.x, translate_pos.y, image.Rect.width, image.Rect.height); } if (have_rotate) { image.SetRotation(rotate_delta); } } else if ("UIText" == type) { UIText text = ((UIText)m_control_table[control_id]); if (have_translate) { text.Rect = new Rect(translate_pos.x, translate_pos.y, text.Rect.width, text.Rect.height); } } } } }
// Use this for initialization public void Start() { m_control_table = new Hashtable(); m_animations = new Hashtable(); XmlElement tempElem = null; string value = ""; TextAsset xml = Resources.Load(m_ui_cfgxml) as TextAsset; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml.text); XmlNode root = xmlDoc.DocumentElement; foreach (XmlNode node1 in root.ChildNodes) { if ("UIElem" == node1.Name) { foreach (XmlNode xmlNode in node1.ChildNodes) { tempElem = (XmlElement)xmlNode; if ("UIButton" == xmlNode.Name) { UIButtonBase button = null; value = tempElem.GetAttribute("rect").Trim(); string[] digital = value.Split(','); value = tempElem.GetAttribute("type").Trim(); if ("click" == value) { button = new UIClickButton(); ((UIClickButton)button).Rect = new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim())); } else if ("push" == value) { button = new UIPushButton(); ((UIPushButton)button).Rect = new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim())); } else if ("select" == value) { button = new UISelectButton(); ((UISelectButton)button).Rect = new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim())); } if (null == button) { continue; } value = tempElem.GetAttribute("id").Trim(); button.Id = int.Parse(value); value = tempElem.GetAttribute("enable").Trim(); if (value.Length > 1) { button.Enable = ("true" == value); } value = tempElem.GetAttribute("visible").Trim(); if (value.Length > 1) { button.Visible = ("true" == value); } tempElem = (XmlElement)xmlNode.SelectSingleNode("Normal"); if (null != tempElem) { value = tempElem.GetAttribute("rect").Trim(); digital = value.Split(','); value = tempElem.GetAttribute("material").Trim(); button.SetTexture(UIButtonBase.State.Normal, LoadUIMaterial(value), new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim()))); } tempElem = (XmlElement)xmlNode.SelectSingleNode("Press"); if (null != tempElem) { value = tempElem.GetAttribute("rect").Trim(); digital = value.Split(','); value = tempElem.GetAttribute("material").Trim(); button.SetTexture(UIButtonBase.State.Pressed, LoadUIMaterial(value), new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim()))); } tempElem = (XmlElement)xmlNode.SelectSingleNode("Disable"); if (null != tempElem) { value = tempElem.GetAttribute("rect").Trim(); digital = value.Split(','); value = tempElem.GetAttribute("material").Trim(); button.SetTexture(UIButtonBase.State.Disabled, LoadUIMaterial(value), new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim()))); } tempElem = (XmlElement)xmlNode.SelectSingleNode("Hover"); if (null != tempElem) { value = tempElem.GetAttribute("rect").Trim(); digital = value.Split(','); value = tempElem.GetAttribute("material").Trim(); button.SetHoverSprite(LoadUIMaterial(value), new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim()))); } m_UIManagerRef.Add(button); m_control_table.Add(button.Id, button); } else if ("UIImage" == xmlNode.Name) { UIImage image = new UIImage(); value = tempElem.GetAttribute("id").Trim(); image.Id = int.Parse(value); value = tempElem.GetAttribute("rect").Trim(); string[] digital = value.Split(','); image.Rect = new Rect(int.Parse(digital[0]), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim())); value = tempElem.GetAttribute("enable").Trim(); if (value.Length > 1) { image.Enable = ("true" == value); } value = tempElem.GetAttribute("visible").Trim(); if (value.Length > 1) { image.Visible = ("true" == value); } tempElem = (XmlElement)xmlNode.SelectSingleNode("Texture"); if (null != tempElem) { value = tempElem.GetAttribute("rect").Trim(); digital = value.Split(','); value = tempElem.GetAttribute("material").Trim(); image.SetTexture(LoadUIMaterial(value), new Rect(int.Parse(digital[0].Trim()), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim()))); } m_UIManagerRef.Add(image); m_control_table.Add(image.Id, image); } else if ("UIText" == xmlNode.Name) { UIText text = new UIText(); value = tempElem.GetAttribute("id").Trim(); text.Id = int.Parse(value); value = tempElem.GetAttribute("rect").Trim(); string[] digital = value.Split(','); text.Rect = new Rect(int.Parse(digital[0]), int.Parse(digital[1].Trim()), int.Parse(digital[2].Trim()), int.Parse(digital[3].Trim())); value = tempElem.GetAttribute("chargap").Trim(); if (value.Length > 1) { text.CharacterSpacing = int.Parse(value); } value = tempElem.GetAttribute("linegap").Trim(); if (value.Length > 1) { text.LineSpacing = int.Parse(value); } value = tempElem.GetAttribute("autoline").Trim(); if (value.Length > 1) { text.AutoLine = ("true" == value); } value = tempElem.GetAttribute("align").Trim(); if (value.Length > 1) { text.AlignStyle = (UIText.enAlignStyle)Enum.Parse(typeof(UIText.enAlignStyle), value); } value = tempElem.GetAttribute("enable").Trim(); if (value.Length > 1) { text.Enable = ("true" == value); } value = tempElem.GetAttribute("visible").Trim(); if (value.Length > 1) { text.Visible = ("true" == value); } value = tempElem.GetAttribute("font").Trim(); text.SetFont(m_font_path + value); value = tempElem.GetAttribute("color").Trim(); if (value.Length > 1) { digital = value.Split(','); text.SetColor(new Color(int.Parse(digital[0].Trim()) / 255.0f, int.Parse(digital[1].Trim()) / 255.0f, int.Parse(digital[2].Trim()) / 255.0f, int.Parse(digital[3].Trim()) / 255.0f)); } text.SetText(xmlNode.InnerText.Trim(new char[] { ' ', '\t', '\r', '\n' })); m_UIManagerRef.Add(text); m_control_table.Add(text.Id, text); } //UIText } // for } else if ("UIAnimation" == node1.Name) { foreach (XmlNode xmlNode in node1.ChildNodes) { tempElem = (XmlElement)xmlNode; if ("Animation" != xmlNode.Name) { continue; } UIAnimations animation = new UIAnimations(); value = tempElem.GetAttribute("id").Trim(); animation.animation_id = int.Parse(value); Debug.Log(value); value = tempElem.GetAttribute("control_id").Trim(); Debug.Log(value); string[] digital = value.Split(','); for (int i = 0; i < digital.Length; ++i) { UIAnimations.ControlData data = new UIAnimations.ControlData(); data.control_id = int.Parse(digital[i].Trim()); animation.control_data.Add(data); } tempElem = (XmlElement)xmlNode.SelectSingleNode("Translate"); if (null != tempElem) { animation.translate_have = true; value = tempElem.GetAttribute("time").Trim(); animation.translate_time = float.Parse(value); value = tempElem.GetAttribute("offset").Trim(); if (value.Length > 0) { digital = value.Split(','); animation.translate_offset.x = int.Parse(digital[0].Trim()); animation.translate_offset.y = int.Parse(digital[1].Trim()); } value = tempElem.GetAttribute("restore").Trim(); if (value.Length > 0) { animation.translate_restore = ("true" == value); } value = tempElem.GetAttribute("loop").Trim(); if (value.Length > 0) { animation.translate_loop = ("true" == value); } value = tempElem.GetAttribute("reverse").Trim(); if (value.Length > 0) { animation.translate_reverse = ("true" == value); } } tempElem = (XmlElement)xmlNode.SelectSingleNode("Rotate"); if (null != tempElem) { animation.rotate_have = true; value = tempElem.GetAttribute("time").Trim(); animation.rotate_time = float.Parse(value); value = tempElem.GetAttribute("angle").Trim(); animation.rotate_angle = Mathf.Deg2Rad * float.Parse(value); value = tempElem.GetAttribute("restore").Trim(); if (value.Length > 0) { animation.rotate_restore = ("true" == value); } value = tempElem.GetAttribute("loop").Trim(); if (value.Length > 0) { animation.rotate_loop = ("true" == value); } value = tempElem.GetAttribute("reverse").Trim(); if (value.Length > 0) { animation.rotate_reverse = ("true" == value); } } m_animations.Add(animation.animation_id, animation); } // for } //if ("UIAnimation" == node1.Name) } //for root }
public override void OnSelectionChanged(UISelectButton button, string option) { this.m_AcceptButton.interactable = true; if (button == this.m_Language) { if (option == "English") { this.m_SelectedLanguage = Language.English; } else if (option == "French") { this.m_SelectedLanguage = Language.French; } else if (option == "Italian") { this.m_SelectedLanguage = Language.Italian; } else if (option == "German") { this.m_SelectedLanguage = Language.German; } else if (option == "Spanish") { this.m_SelectedLanguage = Language.Spanish; } else if (option == "ChineseTraditional") { this.m_SelectedLanguage = Language.ChineseTraditional; } else if (option == "ChineseSimplyfied") { this.m_SelectedLanguage = Language.ChineseSimplyfied; } else if (option == "Portuguese") { this.m_SelectedLanguage = Language.Portuguese; } else if (option == "PortugueseBrazilian") { this.m_SelectedLanguage = Language.PortugueseBrazilian; } else if (option == "Russian") { this.m_SelectedLanguage = Language.Russian; } else if (option == "Polish") { this.m_SelectedLanguage = Language.Polish; } else if (option == "Japanese") { this.m_SelectedLanguage = Language.Japanese; } else if (option == "Korean") { this.m_SelectedLanguage = Language.Korean; } else if (option == "Vietnamese") { this.m_SelectedLanguage = Language.Vietnamese; } else if (option == "Thai") { this.m_SelectedLanguage = Language.Thai; } else if (option == "Czech") { this.m_SelectedLanguage = Language.Czech; } else if (option == "Swedish") { this.m_SelectedLanguage = Language.Swedish; } } }
public virtual void OnSelectionChanged(UISelectButton button, string option) { }
public virtual bool IsMenuSelectButtonEnabled(UISelectButton s) { return(s != null && s.enabled && s.gameObject.activeSelf); }
public override void OnSelectionChanged(UISelectButton button, string option) { this.m_OptionsChanged = true; }