public static MagicUILabel CreateAsComponent(GameObject me) { MagicUILabel result = me.AddComponent <MagicUILabel>(); result._label = me.AddComponent <UILabel>(); return(result); }
protected override void initialize(JSONObject markup) { _chrome = Vector2.one; _margin = Vector2.zero; _key = markup.GetStringSafely("name", ""); bool?iconOnly = markup.GetBoolSafely("iconOnly", false); if (iconOnly.HasValue && iconOnly.Value) { JSONObject icon = markup["icon"]; if (icon != null) { _icon = MagicUIImage.CreateAsComponent(gameObject); _icon.Initialize(icon); } } else { _sprite = gameObject.AddComponent <UISprite>(); _sprite.atlas = MagicUIManager.Instance.Skin.Atlas; _sprite.type = UISprite.Type.Sliced; _sprite.autoResizeBoxCollider = true; _sprite.color = MagicUIManager.Instance.Skin.PrimaryColor; _label = MagicUILabel.CreateAsComponent(gameObject); _label.Initialize(MagicUIManager.Instance.GetString(_key), true, markup); JSONObject frameData = MagicUIManager.Instance.Skin.GetFrameData(ControlType.Button); _sprite.spriteName = frameData["on"].str; if (_label != null) { _label.Color = MagicUIManager.Instance.Skin.FontParameters.DefaultColor; bool?invert = frameData.GetBoolSafely("fgInvert", false); if (invert.HasValue && invert.Value) { _label.Color = MagicUIManager.Instance.Skin.FontParameters.AlternateColor; } } UISpriteData data = MagicUIManager.Instance.Skin.Atlas.GetSprite(_sprite.spriteName); if (frameData.keys.Contains("margin")) { _margin = frameData["margin"].GetVector2(); } if (frameData.keys.Contains("chrome")) { _chrome = frameData["chrome"].GetVector2(); _chrome.x = data.width / (data.width - _chrome.x); _chrome.y = data.height / (data.height - _chrome.y); } } NGUITools.AddWidgetCollider(gameObject); }
protected override void initialize(JSONObject markup) { _sprite = gameObject.AddComponent <UISprite>(); _sprite.atlas = MagicUIManager.Instance.Skin.Atlas; _sprite.type = UISprite.Type.Sliced; _sprite.color = MagicUIManager.Instance.Skin.PrimaryColor; NGUITools.AddWidgetCollider(gameObject); _sprite.autoResizeBoxCollider = true; _key = markup.GetStringSafely("name", ""); _label = MagicUILabel.CreateAsChild(gameObject); _label.Initialize(MagicUIManager.Instance.GetString(_key), false, markup); _input.label = _label.SetForTextBox(); JSONObject frameData = MagicUIManager.Instance.Skin.GetFrameData(ControlType.TextBox); _label.Color = MagicUIManager.Instance.Skin.FontParameters.DefaultColor; bool?invert = frameData.GetBoolSafely("fgInvert", false); if (invert.HasValue && invert.Value) { _label.Color = MagicUIManager.Instance.Skin.FontParameters.AlternateColor; } _input.activeTextColor = _input.label.color; EventDelegate.Set(_input.onSubmit, OnSubmit); _sprite.spriteName = frameData["on"].str; UISpriteData data = MagicUIManager.Instance.Skin.Atlas.GetSprite(_sprite.spriteName); if (frameData.keys.Contains("margin")) { _margin = frameData["margin"].GetVector2(); } _chrome = Vector2.one; if (frameData.keys.Contains("chrome")) { _chrome = frameData["chrome"].GetVector2(); _chrome.x = data.width / (data.width - _chrome.x); _chrome.y = data.height / (data.height - _chrome.y); } }
protected override void initialize(JSONObject markup) { _key = markup.GetStringSafely("name", ""); _label = MagicUILabel.CreateAsComponent(gameObject); _label.Initialize(MagicUIManager.Instance.GetString(_key), false, markup); }