private void SwitchCheck() { if (mLabel == null) { return; } mLabel.effectStyle = UILabel.Effect.Outline; mLabel.effectDistance = 0.5f * Vector2.one; Color tempColor = Color.white; tempColor.r = 46f / 255f; tempColor.g = 78f / 255f; tempColor.b = 103f / 255f; mLabel.effectColor = tempColor; tempColor.r = 1f; tempColor.g = 213f / 255f; tempColor.b = 104f / 255f; mLabel.color = tempColor; if (mLabel.fontSize != 26) { mLabel.fontSize = 26; mLabel.AssumeNaturalSize(); } }
public int CreateItem(GameObject go, int index, int base_max_width) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) UILabel component = this.GetComponent <UILabel>(); UIWidget component2 = this.GetComponent <UIWidget>(); UILabel uILabel = go.AddComponent <UILabel>(); uILabel.pivot = component2.pivot; uILabel.bitmapFont = component.bitmapFont; uILabel.trueTypeFont = component.trueTypeFont; uILabel.fontSize = component.fontSize; uILabel.fontStyle = component.fontStyle; uILabel.text = textItem[index]; uILabel.color = ((!buttonEnable[index]) ? Color.get_gray() : component.color); uILabel.alpha = 1f; uILabel.alignment = component.alignment; uILabel.cachedTransform.set_localPosition(component.cachedTransform.get_localPosition()); uILabel.AssumeNaturalSize(); int result = Mathf.Max(base_max_width, uILabel.width); uILabel.overflowMethod = Overflow.ShrinkContent; return(result); }
/// <summary> /// Label creation function. /// </summary> void CreateLabel(GameObject go) { GUILayout.BeginHorizontal(); Color c = EditorGUILayout.ColorField("Color", mColor, GUILayout.Width(220f)); GUILayout.Label("Color tint the label will start with"); GUILayout.EndHorizontal(); if (mColor != c) { mColor = c; Save(); } if (ShouldCreate(go, NGUISettings.ambigiousFont != null)) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.fontSize = NGUISettings.fontSize; lbl.text = "New Label"; lbl.color = mColor; lbl.AssumeNaturalSize(); Selection.activeGameObject = lbl.gameObject; } }
static int AssumeNaturalSize(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); UILabel obj = (UILabel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UILabel"); obj.AssumeNaturalSize(); return(0); }
/// <summary> /// Toggle creation function. /// </summary> void CreateToggle(GameObject go) { if (NGUISettings.atlas != null) { NGUIEditorTools.DrawSpriteField("Background", "Sprite used for the background", NGUISettings.atlas, mCheckBG, OnCheckBG, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Checkmark", "Sprite used for the checkmark", NGUISettings.atlas, mCheck, OnCheck, GUILayout.Width(120f)); } if (ShouldCreate(go, NGUISettings.atlas != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Toggle"; UISprite bg = NGUITools.AddWidget <UISprite>(go); bg.type = UISprite.Type.Sliced; bg.name = "Background"; bg.depth = depth; bg.atlas = NGUISettings.atlas; bg.spriteName = mCheckBG; bg.width = 26; bg.height = 26; bg.MakePixelPerfect(); UISprite fg = NGUITools.AddWidget <UISprite>(go); fg.name = "Checkmark"; fg.atlas = NGUISettings.atlas; fg.spriteName = mCheck; fg.MakePixelPerfect(); if (NGUISettings.ambigiousFont != null) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.text = go.name; lbl.pivot = UIWidget.Pivot.Left; lbl.transform.localPosition = new Vector3(16f, 0f, 0f); lbl.AssumeNaturalSize(); } // Add a collider NGUITools.AddWidgetCollider(go); // Add the scripts go.AddComponent <UIToggle>().activeSprite = fg; go.AddComponent <UIButton>().tweenTarget = bg.gameObject; go.AddComponent <UIButtonScale>().tweenTarget = bg.transform; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
/// <summary> /// Button creation function. /// </summary> void CreateImageButton(GameObject go) { if (NGUISettings.atlas != null) { NGUIEditorTools.DrawSpriteField("Normal", "Normal state sprite", NGUISettings.atlas, mImage0, OnImage0, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Hover", "Hover state sprite", NGUISettings.atlas, mImage1, OnImage1, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Pressed", "Pressed state sprite", NGUISettings.atlas, mImage2, OnImage2, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Disabled", "Disabled state sprite", NGUISettings.atlas, mImage3, OnImage3, GUILayout.Width(120f)); } if (ShouldCreate(go, NGUISettings.atlas != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Image Button"; UISpriteData sp = NGUISettings.atlas.GetSprite(mImage0); UISprite sprite = NGUITools.AddWidget <UISprite>(go); sprite.type = sp.hasBorder ? UISprite.Type.Sliced : UISprite.Type.Simple; sprite.name = "Background"; sprite.depth = depth; sprite.atlas = NGUISettings.atlas; sprite.spriteName = mImage0; sprite.width = 150; sprite.height = 40; sprite.MakePixelPerfect(); if (NGUISettings.ambigiousFont != null) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.text = go.name; lbl.AssumeNaturalSize(); } // Add a collider NGUITools.AddWidgetCollider(go); // Add the scripts UIImageButton ib = go.AddComponent <UIImageButton>(); ib.target = sprite; ib.normalSprite = mImage0; ib.hoverSprite = mImage1; ib.pressedSprite = mImage2; ib.disabledSprite = mImage3; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
static public int AssumeNaturalSize(IntPtr l) { try { UILabel self = (UILabel)checkSelf(l); self.AssumeNaturalSize(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
/// <summary> /// Label creation function. /// </summary> public static void CreateLabel(GameObject go) { if (ShouldCreate(go, NGUISettings.ambigiousFont != null)) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.fontSize = NGUISettings.fontSize; lbl.color = mColor; lbl.AssumeNaturalSize(); Selection.activeGameObject = lbl.gameObject; } }
static int AssumeNaturalSize(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UILabel obj = (UILabel)ToLua.CheckObject<UILabel>(L, 1); obj.AssumeNaturalSize(); return 0; } catch (Exception e) { return LuaDLL.toluaL_exception(L, e); } }
/// <summary> /// Input field creation function. /// </summary> public static void CreateInput(GameObject go, bool isPassword) { if (ShouldCreate(go, NGUISettings.atlas != null && NGUISettings.ambigiousFont != null)) { int depth = 0; //NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Input"; int padding = 3; UISprite bg = NGUITools.AddWidget <UISprite>(go); bg.type = UISprite.Type.Sliced; bg.name = "Background"; bg.depth = depth; bg.atlas = NGUISettings.atlas; bg.spriteName = mInputBG; bg.pivot = UIWidget.Pivot.Left; bg.width = 400; if (NGUISettings.ambigiousFont != null) { bg.height = NGUISettings.fontSize + padding * 2; } else { bg.height = 32; } bg.transform.localPosition = Vector3.zero; bg.MakePixelPerfect(); UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.pivot = UIWidget.Pivot.Left; lbl.transform.localPosition = new Vector3(padding, 0f, 0f); lbl.multiLine = false; lbl.supportEncoding = false; lbl.width = Mathf.RoundToInt(400f - padding * 2f); lbl.text = "You can type here"; lbl.AssumeNaturalSize(); // Add a collider to the background NGUITools.AddWidgetCollider(go); // Add an input script to the background and have it point to the label UIInput input = go.AddComponent <UIInput>(); input.label = lbl; input.inputType = isPassword ? UIInput.InputType.Password : UIInput.InputType.Standard; // Update the selection Selection.activeGameObject = go; } }
public static int AssumeNaturalSize(IntPtr l) { int result; try { UILabel uILabel = (UILabel)LuaObject.checkSelf(l); uILabel.AssumeNaturalSize(); LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
/// <summary> /// Convenience method -- add a label with default parameters. /// </summary> static public UILabel AddLabel(GameObject go) { UILabel w = NGUITools.AddWidget <UILabel>(go); w.name = "Label"; w.ambigiousFont = ambigiousFont; w.text = "New Label"; w.pivot = pivot; w.width = 120; w.height = Mathf.Max(20, GetInt("NGUI Font Height", 16)); w.fontStyle = fontStyle; w.fontSize = fontSize; w.applyGradient = true; w.gradientBottom = new Color(0.7f, 0.7f, 0.7f); w.AssumeNaturalSize(); return(w); }
/// <summary> /// Button creation function. /// </summary> void CreateButton(GameObject go) { if (NGUISettings.atlas != null) { NGUIEditorTools.SpriteField("Background", "Sliced Sprite for the background", NGUISettings.atlas, mButton, OnButton); } if (ShouldCreate(go, NGUISettings.atlas != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Button"; UISprite bg = NGUITools.AddWidget <UISprite>(go); bg.type = UISprite.Type.Sliced; bg.name = "Background"; bg.depth = depth; bg.atlas = NGUISettings.atlas; bg.spriteName = mButton; bg.width = 200; bg.height = 50; bg.MakePixelPerfect(); if (NGUISettings.font != null) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.font = NGUISettings.font; lbl.text = go.name; lbl.AssumeNaturalSize(); Debug.Log(lbl.height); } // Add a collider NGUITools.AddWidgetCollider(go); // Add the scripts go.AddComponent <UIButton>().tweenTarget = bg.gameObject; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
/// <summary> /// Button creation function. /// </summary> public static void CreateImageButton(GameObject go) { if (ShouldCreate(go, NGUISettings.atlas != null)) { int depth = 0; //NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Image Button"; UISpriteData sp = NGUISettings.atlas.GetSprite(mImage0); UISprite sprite = NGUITools.AddWidget <UISprite>(go); sprite.type = sp.hasBorder ? UISprite.Type.Sliced : UISprite.Type.Simple; sprite.name = "Background"; sprite.depth = depth; sprite.atlas = NGUISettings.atlas; sprite.spriteName = mImage0; sprite.transform.localScale = new Vector3(150f, 40f, 1f); sprite.MakePixelPerfect(); if (NGUISettings.ambigiousFont != null) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.text = go.name; lbl.AssumeNaturalSize(); } // Add a collider NGUITools.AddWidgetCollider(go); // Add the scripts UIImageButton ib = go.AddComponent <UIImageButton>(); ib.target = sprite; ib.normalSprite = mImage0; ib.hoverSprite = mImage1; ib.pressedSprite = mImage2; ib.disabledSprite = mImage3; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
/// <summary> /// Button creation function. /// </summary> public static void CreateButton(GameObject go) { if (ShouldCreate(go, NGUISettings.atlas != null)) { int depth = 0; //NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = "Button"; UISprite bg = NGUITools.AddWidget <UISprite>(go); bg.type = UISprite.Type.Sliced; bg.name = "Background"; bg.depth = depth; bg.atlas = NGUISettings.atlas; bg.spriteName = mButton; bg.width = 200; bg.height = 50; bg.MakePixelPerfect(); if (NGUISettings.ambigiousFont != null) { UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.text = go.name; lbl.AssumeNaturalSize(); } // Add a collider NGUITools.AddWidgetCollider(go); // Add the scripts go.AddComponent <UIButton>().tweenTarget = bg != null ? bg.gameObject : null; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
public void setObjHorizontalAlignment() { if (state == 0) { UISprite sprite = sortObj.transform.FindChild("_Gem").GetComponent <UISprite>(); UILabel label_0 = sortObj.transform.FindChild("_LBuyNum").GetComponent <UILabel>(); UILabel label_1 = sortObj.transform.FindChild("_LInfo").GetComponent <UILabel>(); //get total width float _w = 0; _w += sprite.width; label_0.AssumeNaturalSize(); _w += label_0.width; label_1.AssumeNaturalSize(); _w += label_1.width; //obj Alignment float _m = sprite.width - 5f; label_0.transform.localPosition = new Vector3(_m, label_0.transform.localPosition.y + 1f, 0f); _m += label_0.width + 5f; label_1.transform.localPosition = new Vector3(_m, label_1.transform.localPosition.y, 0f); //main obj Alignment sortObj.transform.localPosition = new Vector3(-(_w * 0.5f), sortObj.transform.localPosition.y); } else if (state == 1) //only label { string[] str = { "판매성공.", "90,000", "코인을 획득 하였습니다." }; float _m = 0, _t = 0; for (int i = 0; i < sortObj.transform.childCount; i++) { UILabel la = sortObj.transform.GetChild(i).GetComponent <UILabel>(); string tmp = i == 0?" ":(i == 1?" ":""); la.text = str[i] + tmp; la.transform.localPosition = new Vector3(_m, la.transform.localPosition.y, 0f); _m += la.width; } sortObj.transform.localPosition = new Vector3(-(_m / 2), sortObj.transform.localPosition.y + 7, 0f); } else if (state == 2) //only label Center { float _m = 0, _t = 0; for (int i = 0; i < sortObj.transform.childCount; i++) { UILabel la = sortObj.transform.GetChild(i).GetComponent <UILabel>(); la.transform.localPosition = new Vector3(_m, la.transform.localPosition.y, 0f); _m += la.width; } sortObj.transform.localPosition = new Vector3(sortObj.transform.localPosition.x - (_m / 2), sortObj.transform.localPosition.y, 0f); } else if (state == 3) //only label Left { float _m = 0, _t = 0; for (int i = 0; i < sortObj.transform.childCount; i++) { UILabel la = sortObj.transform.GetChild(i).GetComponent <UILabel>(); la.transform.localPosition = new Vector3(_m, la.transform.localPosition.y, 0f); _m += la.width; } // sortObj.transform.localPosition = new Vector3(sortObj.transform.localPosition.x, sortObj.transform.localPosition.y, 0f); } // int count = sortObj.transform.childCount; // float _w = 0, _m = 0; // for(int i=0;i<count;i++) // { // System.Type type = sortObj.transform.GetChild(i).GetComponent<UIWidget>().GetType(); // if(type == typeof(UISprite)) // { // UISprite sprite = sortObj.transform.GetChild(i).GetComponent<UISprite>(); // _w += sprite.width; // if(i > 0) // { // // } // _m += sprite.width - 5f; // } // else if(type == typeof(UILabel)) // { // UILabel label = sortObj.transform.GetChild(i).GetComponent<UILabel>(); // label.AssumeNaturalSize(); // _w += label.width; // } // } // sortObj.transform.localPosition = new Vector3(-(_w*0.5f), sortObj.transform.localPosition.y); }
/// <summary> /// Create a popup list or a menu. /// </summary> void CreatePopup(GameObject go, bool isDropDown) { if (NGUISettings.atlas != null) { NGUIEditorTools.DrawSpriteField("Foreground", "Foreground sprite (shown on the button)", NGUISettings.atlas, mListFG, OnListFG, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Background", "Background sprite (envelops the options)", NGUISettings.atlas, mListBG, OnListBG, GUILayout.Width(120f)); NGUIEditorTools.DrawSpriteField("Highlight", "Sprite used to highlight the selected option", NGUISettings.atlas, mListHL, OnListHL, GUILayout.Width(120f)); } if (ShouldCreate(go, NGUISettings.atlas != null && NGUISettings.ambigiousFont != null)) { int depth = NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); go.name = isDropDown ? "Popup List" : "Popup Menu"; UISpriteData sphl = NGUISettings.atlas.GetSprite(mListHL); UISpriteData spfg = NGUISettings.atlas.GetSprite(mListFG); Vector2 hlPadding = new Vector2(Mathf.Max(4f, sphl.paddingLeft), Mathf.Max(4f, sphl.paddingTop)); Vector2 fgPadding = new Vector2(Mathf.Max(4f, spfg.paddingLeft), Mathf.Max(4f, spfg.paddingTop)); // Background sprite UISprite sprite = NGUITools.AddSprite(go, NGUISettings.atlas, mListFG); sprite.depth = depth; sprite.atlas = NGUISettings.atlas; sprite.pivot = UIWidget.Pivot.Left; sprite.width = Mathf.RoundToInt(150f + fgPadding.x * 2f); sprite.height = Mathf.RoundToInt(NGUISettings.fontSize + fgPadding.y * 2f); sprite.transform.localPosition = Vector3.zero; sprite.MakePixelPerfect(); // Text label UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.ambigiousFont = NGUISettings.ambigiousFont; lbl.fontSize = NGUISettings.fontSize; lbl.fontStyle = NGUISettings.fontStyle; lbl.text = go.name; lbl.pivot = UIWidget.Pivot.Left; lbl.cachedTransform.localPosition = new Vector3(fgPadding.x, 0f, 0f); lbl.AssumeNaturalSize(); // Add a collider NGUITools.AddWidgetCollider(go); // Add the popup list UIPopupList list = go.AddComponent <UIPopupList>(); list.atlas = NGUISettings.atlas; list.ambigiousFont = NGUISettings.ambigiousFont; list.fontSize = NGUISettings.fontSize; list.fontStyle = NGUISettings.fontStyle; list.backgroundSprite = mListBG; list.highlightSprite = mListHL; list.padding = hlPadding; if (isDropDown) { EventDelegate.Add(list.onChange, lbl.SetCurrentSelection); } for (int i = 0; i < 5; ++i) { list.items.Add(isDropDown ? ("List Option " + i) : ("Menu Option " + i)); } // Add the scripts go.AddComponent <UIButton>().tweenTarget = sprite.gameObject; go.AddComponent <UIPlaySound>(); Selection.activeGameObject = go; } }
void insertSelectPanel(StorageItem im) { if (itemMg == im) { return; } itemMg = im; GameObject panel = mainObj.transform.FindChild("_SelectItem").gameObject; if (!panel.activeInHierarchy) { panel.SetActive(true); } panel.transform.FindChild("_Image").GetComponent <UISprite> ().spriteName = im.imageName; UILabel label = panel.transform.FindChild("_Name").GetComponent <UILabel> (); label.text = im.itemName; label.AssumeNaturalSize(); //remove for (int i = 0; i < panel.transform.FindChild("_Name").childCount; i++) { DestroyImmediate(panel.transform.FindChild("_Name").transform.GetChild(i).gameObject); } panel.transform.FindChild("_Info").GetComponent <UILabel> ().text = im.itemInfo; switch (m_state) { case StorageState.TREASURE_BOX: panel.transform.FindChild("_BgNum").transform.FindChild("_Name").GetComponent <UILabel> ().text = "수요"; panel.transform.FindChild("_BgNum").transform.FindChild("_ImageKey").GetComponent <UISprite> ().spriteName = "Detail_Icon_Key_01"; panel.transform.FindChild("_BgNum").transform.FindChild("_Num").GetComponent <UILabel> ().text = "8/1"; panel.transform.FindChild("_BtnBuy").transform.FindChild("_Name").GetComponent <UILabel> ().text = "사용"; break; case StorageState.EQUIL: panel.transform.FindChild("_BgNum").transform.FindChild("_Name").GetComponent <UILabel> ().text = "단가"; panel.transform.FindChild("_BgNum").transform.FindChild("_ImageKey").GetComponent <UISprite> ().spriteName = "Detail_Icon_Price"; panel.transform.FindChild("_BgNum").transform.FindChild("_Num").GetComponent <UILabel> ().text = "999,999"; panel.transform.FindChild("_BtnBuy").transform.FindChild("_Name").GetComponent <UILabel> ().text = "판매"; float nx = label.width + 100; GameObject abilltyPanel = SKCommon.loadPrefeb("_PAbillity", label.gameObject); for (int i = 3; i >= 0; i--) { bool bt = Random.Range(0, 2) == 0 ? false : true; if (!bt) { DestroyImmediate(abilltyPanel.transform.GetChild(i).gameObject); } } abilltyPanel.GetComponent <UIGrid>().Reposition(); abilltyPanel.transform.localPosition = new Vector3(nx, 0f, 0f); //info label hiden panel.transform.FindChild("_Info").gameObject.SetActive(false); break; case StorageState.TOOLS: panel.transform.FindChild("_BgNum").transform.FindChild("_Name").GetComponent <UILabel> ().text = "단가"; panel.transform.FindChild("_BgNum").transform.FindChild("_ImageKey").GetComponent <UISprite> ().spriteName = "Detail_Icon_Price"; panel.transform.FindChild("_BgNum").transform.FindChild("_Num").GetComponent <UILabel> ().text = "900"; panel.transform.FindChild("_BtnBuy").transform.FindChild("_Name").GetComponent <UILabel> ().text = "판매"; break; } }