public void Select(bool bSelect) { selectPanelButton.Set(bSelect); if (bSelect) { buttonText.SetColor(ColorName.fontColor_yellow); currentValueText.SetColor(ColorName.fontColor_yellow); nextValueText.SetColor(ColorName.fontColor_yellow); arrowImage.SetTexture(arenaMaterial, ArenaMenuTexturePosition.ArrowSelected, AutoRect.AutoSize(ArenaMenuTexturePosition.ArrowSelected)); for (int i = 0; i < 10; i++) { starsBackground[i].SetTexture(arenaMaterial, ArenaMenuTexturePosition.StarEmptySelected, AutoRect.AutoSize(ArenaMenuTexturePosition.StarEmptySelected)); stars[i].SetTexture(arenaMaterial, ArenaMenuTexturePosition.StarFullSelected, AutoRect.AutoSize(ArenaMenuTexturePosition.StarFullSelected)); } } else { buttonText.SetColor(ColorName.fontColor_orange); currentValueText.SetColor(ColorName.fontColor_orange); nextValueText.SetColor(ColorName.fontColor_orange); arrowImage.SetTexture(arenaMaterial, ArenaMenuTexturePosition.Arrow, AutoRect.AutoSize(ArenaMenuTexturePosition.Arrow)); for (int i = 0; i < 10; i++) { starsBackground[i].SetTexture(arenaMaterial, ArenaMenuTexturePosition.StarEmpty, AutoRect.AutoSize(ArenaMenuTexturePosition.StarEmpty)); stars[i].SetTexture(arenaMaterial, ArenaMenuTexturePosition.StarFull, AutoRect.AutoSize(ArenaMenuTexturePosition.StarFull)); } } }
public override void Draw() { base.Draw(); if (m_State == State.Normal) { m_Text.SetColor(m_NormalColor); } else if (m_State == State.Pressed) { m_Text.SetColor(m_PressedColor); } m_Text.Draw(); }
/// <summary> /// Updates the UI fields for data about the focused character (e.g. name, price). /// </summary> private void UpdateFocusAreaFields() { if (m_focusedItem == null) { return; } // Get character type of focused item int scrollItemIndex = m_focusedItem.ScrollItem.Index; // Get character struct CharacterResource.CharacterStruct charStruct = m_characterResource.GetCharacterStruct((CharacterType)(scrollItemIndex)); m_characterNameText.SetText(charStruct.Name); // Show/hide buttons or text depending on whether character is owned and/or buyable if (m_focusedItem.IsOwned) { // Show play character and share buttons m_playCharacterBtn.gameObject.SetActive(true); m_charSelectShareBtn.gameObject.SetActive(true); // Hide the buy button and locked sprites m_buyCharacterBtn.gameObject.SetActive(false); m_characterPriceText.SetText(""); m_lockedCharacterRoot.gameObject.SetActive(false); m_shareLockedSprite.gameObject.SetActive(false); // Set color of character name text m_characterNameText.SetColor(m_ownedCharNameColor); } else { // Hide play button m_playCharacterBtn.gameObject.SetActive(false); // Hide share button and show locked sprite m_charSelectShareBtn.gameObject.SetActive(false); m_shareLockedSprite.gameObject.SetActive(true); // Set color of character name text m_characterNameText.SetColor(m_unownedCharNameColor); // Show/hide buy button and locked sprite depending on whether character is buyable m_buyCharacterBtn.gameObject.SetActive(charStruct.IsBuyable); m_lockedCharacterRoot.gameObject.SetActive(!charStruct.IsBuyable); // If buyable, show character price. Else, leave price text empty. // TODO: Format price with the proper currency m_characterPriceText.SetText(charStruct.IsBuyable ? "$" + charStruct.Price.ToString("0.00") : ""); } }
void OnEnable() { if (target != null) { Apply(target.Button.interactable); } // UITextが色指定を行っている場合は現在の色をその色に変更. var selectionColor = uiText.SelectionColor; if (selectionColor != null) { enableColor = selectionColor.Color; if (selectionColor.ShadowColor.HasValue) { enableShadowColor = selectionColor.ShadowColor.Value; } if (selectionColor.OutlineColor.HasValue) { enableOutlineColor = selectionColor.OutlineColor.Value; } uiText.SetColor(null); } }
// 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 }