MakePixelPerfect() 공개 메소드

Text is pixel-perfect when its scale matches the size.
public MakePixelPerfect ( ) : void
리턴 void
예제 #1
0
    public void AddText(string txt)
    {
        if (textList.Count == 0)
        {
            UILabel label = msg.GetComponent <UILabel>();
            label.text = txt;
            label.MakePixelPerfect();
            AddLabel(label);
            msg.name = "0";
        }
        else if (textList.Count >= MaxLine)
        {
            UILabel label = textList[0];
            textList.Remove(label);
            Vector3 pos  = msg.transform.localPosition;
            UILabel temp = msg.GetComponent <UILabel>();
            pos.y -= temp.height;
            label.transform.localPosition = pos;
            label.text = txt;
            label.MakePixelPerfect();
            AddLabel(label);
            msg = label.gameObject;
        }
        else
        {
            GameObject obj = GameObject.Instantiate(msg) as GameObject;
            obj.transform.parent = msg.transform.parent;
            obj.name             = (int.Parse(msg.name) + 1).ToString();
            Vector3 pos   = msg.transform.localPosition;
            UILabel label = msg.GetComponent <UILabel>();
            pos.y -= label.height;
            obj.transform.localPosition = pos;
            label      = obj.GetComponent <UILabel>();
            label.text = txt;
            label.MakePixelPerfect();
            AddLabel(label);
            msg = obj;
        }

        UIDraggablePanel panel = GetComponent <UIDraggablePanel>();
        float            size  = panel.bounds.size.y;

        if (size > 300)
        {
            Vector3 pos  = panel.transform.localPosition;
            Vector3 pos1 = msg.transform.localPosition;
            pos.y = (Mathf.Abs(pos1.y) - 152 - pos.y);
            panel.MoveRelative(pos);
        }
    }
예제 #2
0
        public void ShowGpsInfo()
        {
            _gpsInfoLabel.gameObject.SetActive(true);
            _gpsInfoLabel.text = string.Format("{0}\nID:{1}\nIP:{3}\n所在地:{2}", Info.NickM,
                                               Info.Id, HasGpsInfo ?
                                               Info.Country : "未提供位置信息\n请开启位置服务,并给予应用相应权限",
                                               Ip);
            _gpsInfoLabel.MakePixelPerfect();

            UISprite sp = _gpsInfoLabel.transform.GetChild(0).GetComponent <UISprite>();

            sp.width  = _gpsInfoLabel.width + 50;
            sp.height = _gpsInfoLabel.height + 50;
        }
예제 #3
0
	/// <summary>
	/// Checkbox creation function.
	/// </summary>

	void CreateCheckbox (GameObject go)
	{
		if (NGUISettings.atlas != null)
		{
			NGUIEditorTools.SpriteField("Background", "Sprite used for the background", NGUISettings.atlas, mCheckBG, OnCheckBG);
			NGUIEditorTools.SpriteField("Checkmark", "Sprite used for the checkmark", NGUISettings.atlas, mCheck, OnCheck);
		}

		if (ShouldCreate(go, NGUISettings.atlas != null))
		{
			int depth = NGUITools.CalculateNextDepth(go);
			go = NGUITools.AddChild(go);
			go.name = "Checkbox";

			UISlicedSprite bg = NGUITools.AddWidget<UISlicedSprite>(go);
			bg.name = "Background";
			bg.depth = depth;
			bg.atlas = NGUISettings.atlas;
			bg.spriteName = mCheckBG;
			bg.transform.localScale = new Vector3(26f, 26f, 1f);
			bg.MakePixelPerfect();

			UISprite fg = NGUITools.AddWidget<UISprite>(go);
			fg.name = "Checkmark";
			fg.atlas = NGUISettings.atlas;
			fg.spriteName = mCheck;
			fg.MakePixelPerfect();

			if (NGUISettings.font != null)
			{
				UILabel lbl = NGUITools.AddWidget<UILabel>(go);
				lbl.font = NGUISettings.font;
				lbl.text = go.name;
				lbl.pivot = UIWidget.Pivot.Left;
				lbl.transform.localPosition = new Vector3(16f, 0f, 0f);
				lbl.MakePixelPerfect();
			}

			// Add a collider
			NGUITools.AddWidgetCollider(go);

			// Add the scripts
			go.AddComponent<UICheckbox>().checkSprite = fg;
			go.AddComponent<UIButton>().tweenTarget = bg.gameObject;
			go.AddComponent<UIButtonScale>().tweenTarget = bg.transform;
			go.AddComponent<UIButtonSound>();

			Selection.activeGameObject = go;
		}
	}
    protected override IEnumerator LoadContent(Action onComplete)
    {
        yield return(new WaitForSeconds(0.75f));        // Simulate loading

        Texture2D logoTexture = DemoContentServer.Instance.sponsoredLogo;

        partnerLogo.mainTexture = logoTexture;
        partnerLogo.MakePixelPerfect();

        Texture2D contentTexture = DemoContentServer.Instance.sponsoredPicture;

        contentImage.mainTexture = contentTexture;
        contentImage.MakePixelPerfect();

        // resize textures if non-retina display (only scales the GameObject at the moment)
        if (!AppGUISettings.IS_RETINA)
        {
            partnerLogo.transform.localScale = new Vector3(logoTexture.width / 2, logoTexture.height / 2, 0f);
            //contentImage.transform.localScale = new Vector3(contentTexture.width / 2, contentTexture.height / 2, 0f);
        }

        // scale image to fit the panel
        UIPanel panel          = GetComponent <UIPanel>();
        float   panelClippingX = panel.clipRange.z;
        float   panelClippingY = panel.clipRange.w;
        float   scaleMultX     = panelClippingX / contentImage.transform.localScale.x;
        float   scaleMultY     = panelClippingY / contentImage.transform.localScale.y;

        if (scaleMultX > scaleMultY)
        {
            contentImage.transform.localScale = new Vector3(contentTexture.width * scaleMultX, contentTexture.height * scaleMultX, 0f);
        }
        else
        {
            contentImage.transform.localScale = new Vector3(contentTexture.width * scaleMultY, contentTexture.height * scaleMultY, 0f);
        }

        // Need to set the pivot here as it's not exposed when no texture present in the editor
        partnerLogo.pivot = UIWidget.Pivot.BottomRight;

        contentHeaderLabel.text      = DemoContentServer.Instance.sponsoredHeader;
        contentDescriptionLabel.text = DemoContentServer.Instance.sponsoredDescription;
        contentHeaderLabel.MakePixelPerfect();
        contentDescriptionLabel.MakePixelPerfect();

        onComplete();

        yield return(null);
    }
예제 #5
0
    /// <summary>
    /// Button creation function.
    /// </summary>

    void CreateButton(GameObject go)
    {
        if (UISettings.atlas != null)
        {
            GUILayout.BeginHorizontal();
            string bg = UISpriteInspector.SpriteField(UISettings.atlas, "Background", mButton, GUILayout.Width(200f));
            GUILayout.Space(20f);
            GUILayout.Label("Sliced Sprite for the background");
            GUILayout.EndHorizontal();
            if (mButton != bg)
            {
                mButton = bg; Save();
            }
        }

        if (ShouldCreate(go, UISettings.atlas != null))
        {
            int depth = NGUITools.CalculateNextDepth(go);
            go      = NGUITools.AddChild(go);
            go.name = "Button";

            UISlicedSprite bg = NGUITools.AddWidget <UISlicedSprite>(go);
            bg.name                 = "Background";
            bg.depth                = depth;
            bg.atlas                = UISettings.atlas;
            bg.spriteName           = mButton;
            bg.transform.localScale = new Vector3(150f, 40f, 1f);
            bg.MakePixelPerfect();

            if (UISettings.font != null)
            {
                UILabel lbl = NGUITools.AddWidget <UILabel>(go);
                lbl.font = UISettings.font;
                lbl.text = go.name;
                lbl.MakePixelPerfect();
            }

            // Add a collider
            NGUITools.AddWidgetCollider(go);

            // Add the scripts
            go.AddComponent <UIButton>().tweenTarget = bg.gameObject;
            go.AddComponent <UIButtonScale>();
            go.AddComponent <UIButtonOffset>();
            go.AddComponent <UIButtonSound>();

            Selection.activeGameObject = go;
        }
    }
예제 #6
0
    /// <summary>
    /// Font selection callback.
    /// </summary>

    void OnSelectFont(UnityEngine.Object obj)
    {
        if (mLabel != null)
        {
            NGUIEditorTools.RegisterUndo("Font Selection", mLabel);
            bool resize = (mLabel.font == null);
            mLabel.font = mLabel.font == null?UIFont.CreateInstance <UIFont>() : mLabel.font;

            mLabel.TrueTypeFont = obj as Font;
            if (resize)
            {
                mLabel.MakePixelPerfect();
            }
        }
    }
예제 #7
0
    public void SetInfo(string name, string iconName)
    {
        mNameText.text = name;
        mNameText.MakePixelPerfect();

        mIconSpr.spriteName = iconName;
        mIconSpr.MakePixelPerfect();

        float textLength  = mNameText.font.CalculatePrintedSize(name, true, UIFont.SymbolStyle.None).x *mNameText.font.size;
        float iconLength  = mIconSpr.transform.localScale.x;
        float totalLength = textLength + iconLength;

        mIconSpr.transform.localPosition  = new Vector3(-totalLength / 2f - 2f, 0, 0);
        mNameText.transform.localPosition = new Vector3(iconLength - totalLength / 2f + 2, 0, 0);
    }
예제 #8
0
    public static UILabel CreateLabel(GameObject parent, string text, int fontSize, bool useArtFont)
    {
        int     depth = NGUITools.CalculateNextDepth(parent);
        UILabel lbl   = NGUITools.AddWidget <UILabel>(parent);

        lbl.depth = depth + 1;
        lbl.text  = text;
        if (useArtFont)
        {
            lbl.TrueTypeFont = UIFont.ArtFont;
        }
        lbl.MakePixelPerfect();
        lbl.transform.localScale = new UnityEngine.Vector3(fontSize, fontSize, 1);
        return(lbl);
    }
예제 #9
0
    private void PlayTipShowTween(string content)
    {
        m_TipLabel.text = content;
        m_TipLabel.MakePixelPerfect();
        float   tipLblHeight = m_TipLabel.relativeSize.y * m_TipLabel.font.size;
        Vector3 bgScale      = m_TipBg.transform.localScale;

        bgScale.y = tipLblHeight + m_BorderY * 2;
        bgScale.x = m_TipLabel.relativeSize.x * m_TipLabel.font.size + 10f;
        m_TipBg.transform.localScale = bgScale;
        if (!m_TipShow)
        {
            m_TipScaleTween.Play(true);
        }
    }
예제 #10
0
    /// <summary>
    /// Button creation function.
    /// </summary>

    void CreateImageButton(GameObject go)
    {
        if (NGUISettings.atlas != null)
        {
            NGUIEditorTools.SpriteField("Normal", "Normal state sprite", NGUISettings.atlas, mImage0, OnImage0);
            NGUIEditorTools.SpriteField("Hover", "Hover state sprite", NGUISettings.atlas, mImage1, OnImage1);
            NGUIEditorTools.SpriteField("Pressed", "Pressed state sprite", NGUISettings.atlas, mImage2, OnImage2);
            NGUIEditorTools.SpriteField("Disabled", "Disabled state sprite", NGUISettings.atlas, mImage3, OnImage3);
        }

        if (ShouldCreate(go, NGUISettings.atlas != null))
        {
            int depth = NGUITools.CalculateNextDepth(go);
            go      = NGUITools.AddChild(go);
            go.name = "Image Button";

            UIAtlas.Sprite sp     = NGUISettings.atlas.GetSprite(mImage0);
            UISprite       sprite = NGUITools.AddWidget <UISprite>(go);
            sprite.type                 = (sp.inner == sp.outer) ? UISprite.Type.Simple : UISprite.Type.Sliced;
            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.font != null)
            {
                UILabel lbl = NGUITools.AddWidget <UILabel>(go);
                lbl.font = NGUISettings.font;
                lbl.text = go.name;
                lbl.MakePixelPerfect();
            }

            // 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;
            go.AddComponent <UIButtonSound>();

            Selection.activeGameObject = go;
        }
    }
    public void AddHistory(string history)
    {
        UILabel lb = Instantiate(m_HistoryLbPrefab) as UILabel;

        lb.transform.parent        = m_TableUI.transform;
        lb.transform.localPosition = Vector3.zero;
        lb.transform.localRotation = Quaternion.identity;
        lb.MakePixelPerfect();

        lb.text = history;

        m_HistoryObjs.Add(lb.gameObject);

//		m_TableUI.repositionNow = true;
        repositionNow_cnt = 2;
    }
예제 #12
0
    /// <summary>
    /// Input field creation function.
    /// </summary>

    void CreateInput(GameObject go)
    {
        if (NGUISettings.atlas != null)
        {
            NGUIEditorTools.SpriteField("Background", "Sliced Sprite for the background", NGUISettings.atlas, mInputBG, OnInputBG);
        }

        if (ShouldCreate(go, NGUISettings.atlas != null && NGUISettings.font != null))
        {
            int depth = NGUITools.CalculateNextDepth(go);
            go      = NGUITools.AddChild(go);
            go.name = "Input";

            float padding = 3f;

            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.transform.localScale    = new Vector3(400f, NGUISettings.font.size + padding * 2f, 1f);
            bg.transform.localPosition = Vector3.zero;
            bg.MakePixelPerfect();

            UILabel lbl = NGUITools.AddWidget <UILabel>(go);
            lbl.font  = NGUISettings.font;
            lbl.pivot = UIWidget.Pivot.Left;
            lbl.transform.localPosition = new Vector3(padding, 0f, 0f);
            lbl.multiLine       = false;
            lbl.supportEncoding = false;
            lbl.lineWidth       = Mathf.RoundToInt(400f - padding * 2f);
            lbl.text            = "You can type here";
            lbl.MakePixelPerfect();

            // 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;

            // Update the selection
            Selection.activeGameObject = go;
        }
    }
예제 #13
0
    /// <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.transform.localScale = new Vector3(150f, 40f, 1f);
            bg.MakePixelPerfect();

            if (NGUISettings.font != null)
            {
                UILabel lbl = NGUITools.AddWidget <UILabel>(go);
                lbl.font = NGUISettings.font;
                lbl.text = go.name;
                if (lbl.font.dynamicFont)
                {
                    lbl.transform.localPosition = new Vector3(0f, 0f, -1f);
                }
                lbl.MakePixelPerfect();
            }

            // Add a collider
            NGUITools.AddWidgetCollider(go);

            // Add the scripts
            go.AddComponent <UIButton>().tweenTarget = bg.gameObject;
            go.AddComponent <UIButtonScale>();
            go.AddComponent <UIButtonOffset>();
            go.AddComponent <UIButtonSound>();

            Selection.activeGameObject = go;
        }
    }
예제 #14
0
    public static int MakePixelPerfect(IntPtr l)
    {
        int result;

        try
        {
            UILabel uILabel = (UILabel)LuaObject.checkSelf(l);
            uILabel.MakePixelPerfect();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
예제 #15
0
    /// <summary>
    /// Toggle creation function.
    /// </summary>

    public static void CreateToggle(GameObject go)
    {
        if (ShouldCreate(go, NGUISettings.atlas != null))
        {
            int depth = 0;            //NGUITools.CalculateNextDepth(go);
            go      = NGUITools.AddChild(go);
            go.name = "Toggle";

            UISprite bg = NGUITools.AddWidget <UISprite>(go);
            bg.type       = UISprite.Type.Sliced;
            bg.name       = "1-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       = "2-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.MakePixelPerfect();
            }

            // 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;
        }
    }
예제 #16
0
    private GameObject _Show(string text, UIWidget.Pivot pivot)
    {
        gameObject.SetActive(true);
        Lbl.pivot = pivot;
        switch (pivot)
        {
        case UIWidget.Pivot.TopLeft:
            Lbl.transform.localPosition = new Vector3(PaddingLeft, -PaddingTop);
            break;

        case UIWidget.Pivot.Top:
            Lbl.transform.localPosition = new Vector3(0, -PaddingTop);
            break;

        case UIWidget.Pivot.TopRight:
            break;

        case UIWidget.Pivot.Left:
            break;

        case UIWidget.Pivot.Center:
            Lbl.transform.localPosition = Vector3.zero;
            break;

        case UIWidget.Pivot.Right:
            break;

        case UIWidget.Pivot.BottomLeft:
            break;

        case UIWidget.Pivot.Bottom:
            break;

        case UIWidget.Pivot.BottomRight:
            break;
        }
        Lbl.text = text;
        Lbl.MakePixelPerfect();

        Spr.pivot = pivot;
        Spr.transform.localPosition = Vector3.zero;
        Spr.width  = Lbl.width + PaddingLeft + PaddingRight;
        Spr.height = Lbl.height + PaddingTop + PaddingBottom;
        return(gameObject);
    }
예제 #17
0
    private void AddHistroy(NPCTalkHistroy.Histroy histroyMsg)
    {
        GameObject go      = CreateGo();
        UILabel    uiLabel = go.GetComponent <UILabel>();

        if (null != uiLabel)
        {
            if (null != histroyMsg.npcName && null != histroyMsg.countent)
            {
                string content = histroyMsg.countent.Replace("\n", string.Empty);
                uiLabel.text = string.Format(m_MsgFormat, histroyMsg.npcName, content);
                uiLabel.MakePixelPerfect();
            }
        }
        go.SetActive(true);
        m_MsgGoList.Add(go);
        Reposition();
    }
예제 #18
0
    // Update is called once per frame
    private void Update()
    {
        //
        if (!m_bInit)
        {
            return;
        }
        if (m_UpdateTextNow)
        {
            UpdateText();
            m_UpdateTextNow = false;

            if (m_Snap)
            {
                m_label.MakePixelPerfect();
            }
        }
    }
예제 #19
0
        private void _createHistoryLabel()
        {
            if (Server_Common.Utils.IsGameOver())
            {
                if (_isTurnOver)
                {
                    _gameoverTxt1.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverB1") as Texture2D);
                    _gameoverTxt2.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverB2") as Texture2D);
                }
                else
                {
                    _gameoverTxt1.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverA1") as Texture2D);
                    _gameoverTxt2.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverA2") as Texture2D);
                }
                _gameoverTxt1.MakePixelPerfect();
                _gameoverTxt2.MakePixelPerfect();
            }
            Api_Result <List <User_HistoryFmt> > api_Result = new Api_get_Member().HistoryList();

            for (int i = 0; i < api_Result.data.Count; i++)
            {
                User_HistoryFmt user_HistoryFmt = api_Result.data[i];
                if (user_HistoryFmt != null)
                {
                    UILabel uILabel = UnityEngine.Object.Instantiate(_historyLabel);
                    uILabel.transform.parent        = _historyLabel.transform.parent;
                    uILabel.transform.localPosition = _historyLabel.transform.localPosition;
                    uILabel.transform.localScale    = Vector3.one;
                    uILabel.text = _setHistoryType(user_HistoryFmt);
                    uILabel.MakePixelPerfect();
                    _lstHistoryLabel.Add(uILabel);
                    if (user_HistoryFmt.Type == HistoryType.GameOverLost)
                    {
                        UILabel uILabel2 = UnityEngine.Object.Instantiate(_historyLabel);
                        uILabel2.transform.parent        = _historyLabel.transform.parent;
                        uILabel2.transform.localPosition = _historyLabel.transform.localPosition;
                        uILabel2.transform.localScale    = Vector3.one;
                        uILabel2.text = "\u3000\u3000\u3000\u3000\u3000\u3000 敗戦";
                        uILabel2.MakePixelPerfect();
                        _lstHistoryLabel.Add(uILabel2);
                    }
                }
            }
        }
        private void _createHistoryLabel()
        {
            if (Utils.IsGameOver())
            {
                if (this._isTurnOver)
                {
                    this._gameoverTxt1.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverB1") as Texture2D);
                    this._gameoverTxt2.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverB2") as Texture2D);
                }
                else
                {
                    this._gameoverTxt1.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverA1") as Texture2D);
                    this._gameoverTxt2.mainTexture = (Resources.Load("Textures/Ending/txt_gamoverA2") as Texture2D);
                }
                this._gameoverTxt1.MakePixelPerfect();
                this._gameoverTxt2.MakePixelPerfect();
            }
            Api_Result <List <User_HistoryFmt> > api_Result = new Api_get_Member().HistoryList();

            for (int i = 0; i < api_Result.data.get_Count(); i++)
            {
                User_HistoryFmt user_HistoryFmt = api_Result.data.get_Item(i);
                if (user_HistoryFmt != null)
                {
                    UILabel uILabel = Object.Instantiate <UILabel>(this._historyLabel);
                    uILabel.get_transform().set_parent(this._historyLabel.get_transform().get_parent());
                    uILabel.get_transform().set_localPosition(this._historyLabel.get_transform().get_localPosition());
                    uILabel.get_transform().set_localScale(Vector3.get_one());
                    uILabel.text = this._setHistoryType(user_HistoryFmt);
                    uILabel.MakePixelPerfect();
                    this._lstHistoryLabel.Add(uILabel);
                    if (user_HistoryFmt.Type == HistoryType.GameOverLost)
                    {
                        UILabel uILabel2 = Object.Instantiate <UILabel>(this._historyLabel);
                        uILabel2.get_transform().set_parent(this._historyLabel.get_transform().get_parent());
                        uILabel2.get_transform().set_localPosition(this._historyLabel.get_transform().get_localPosition());
                        uILabel2.get_transform().set_localScale(Vector3.get_one());
                        uILabel2.text = "\u3000\u3000\u3000\u3000\u3000\u3000 敗戦";
                        uILabel2.MakePixelPerfect();
                        this._lstHistoryLabel.Add(uILabel2);
                    }
                }
            }
        }
예제 #21
0
파일: UIUtil.cs 프로젝트: atom-chen/tianyu
    public static UILabel Str2CentLab(GameObject parent, string in_str, UIFont mFont, Color color)
    {
        int     nextDepth = NGUITools.CalculateNextDepth(parent);
        UILabel lbl       = NGUITools.AddWidget <UILabel>(parent);

        lbl.name                 = "Label_text";
        lbl.depth                = nextDepth;
        lbl.bitmapFont           = mFont;
        lbl.pivot                = UILabel.Pivot.Center;
        lbl.transform.localScale = new Vector3(mFont.defaultSize, mFont.defaultSize, 1f);
        lbl.MakePixelPerfect();
        lbl.supportEncoding = true;
        lbl.symbolStyle     = NGUIText.SymbolStyle.Normal;//UIFont.SymbolStyle.Uncolored;  3.8.2更新导致的修改, by吴江 2015/7/2

        lbl.color = color;

        lbl.text = in_str;
        return(lbl);
    }
예제 #22
0
    void UpdateMapPos()
    {
        mWnd.transform.localPosition     = new Vector3(-Convert.ToInt32(mMapSize.x / 2 + 1), -Convert.ToInt32(mMapSize.y / 2 + 1), 0);
        mSpCenterBg.transform.localScale = new Vector3(mMapSize.x - 30, mMapSize.y, 1);
        mMiniMapTex.transform.localScale = new Vector3(mMapSize.x, mMapSize.y, 1);
        mSpLeftBg.transform.localScale   = new Vector3(20, mMapSize.y, 1);
        mSpRightBg.transform.localScale  = new Vector3(33, mMapSize.y, 1);

        mSpLeftBg.transform.parent.localPosition  = new Vector3(-Convert.ToInt32(mMapSize.x / 2 + 10), 0, 0);
        mSpRightBg.transform.parent.localPosition = new Vector3(Convert.ToInt32(mMapSize.x / 2 - 15), 0, 0);
        mPlayerPosText.transform.localPosition    = new Vector3(15, -Convert.ToInt32(mMapSize.y / 2 - 10), 0);
        mPlayerPosText.MakePixelPerfect();
        mTimeLabel.transform.localPosition = new Vector3(Convert.ToInt32(mMapSize.x / 2 + 5), Convert.ToInt32(mMapSize.y / 2 - 12), 0);
        mTimeLabel.MakePixelPerfect();

        mRTopBtns.transform.localPosition    = new Vector3(0, Convert.ToInt32(mMapSize.y / 2), 0);
        mRBottomBtns.transform.localPosition = new Vector3(0, -Convert.ToInt32(mMapSize.y / 2), 0);
        mWeatherSpr.transform.localPosition  = new Vector3(0, Convert.ToInt32(mMapSize.y / 2 - 12), 0);
        mChangeSize.transform.localPosition  = new Vector3(0, -Convert.ToInt32(mMapSize.y / 2), 0);

        mSubInfoPanel.clipRange = new Vector4(-15, 0, mMapSize.x - 25, mMapSize.y);

        mSpLeftBg_1.transform.localPosition = mSpLeftBg.transform.localPosition;
        mSpLeftBg_1.transform.localScale    = mSpLeftBg.transform.localScale;
        mTexLeftBg.transform.localPosition  = new Vector3(mSpLeftBg.transform.localPosition.x, mSpLeftBg.transform.localPosition.y, -2);
        mTexLeftBg.transform.localScale     = mSpLeftBg.transform.localScale;

        mSpRightBg_1.transform.localPosition = mSpRightBg.transform.localPosition;
        mSpRightBg_1.transform.localScale    = mSpRightBg.transform.localScale;
        mTexRightBg.transform.localPosition  = new Vector3(mSpRightBg.transform.localPosition.x, mSpRightBg.transform.localPosition.y, -2);
        mTexRightBg.transform.localScale     = mSpRightBg.transform.localScale;

        mTexCenterBg.transform.localPosition = new Vector3(mSpCenterBg.transform.localPosition.x, mSpCenterBg.transform.localPosition.y, -2);
        mTexCenterBg.transform.localScale    = mSpCenterBg.transform.localScale;

        // map arraw
        for (int i = 0; i < mMapArrowList.Count; i++)
        {
            mMapArrowList[i].visualWidth  = mMapSize.x - 20;
            mMapArrowList[i].visualHeight = mMapSize.y - 10;
        }
    }
예제 #23
0
    void Update()
    {
        // Update the HP & DP on the Unit's GUI Button
        if (UnitButton != null)
        {
            UILabel UnitHPLabel = GameObject.Find(UnitButton.name + "/HPLabel").GetComponent <UILabel>();
            UILabel UnitDPLabel = GameObject.Find(UnitButton.name + "/DPLabel").GetComponent <UILabel>();

            UnitHPLabel.text = "HP :" + HP;
            UnitDPLabel.text = "DP :" + DP;

            UnitHPLabel.MakePixelPerfect();
            UnitDPLabel.MakePixelPerfect();

            UnitHPLabel.MarkAsChanged();
            UnitDPLabel.MarkAsChanged();
        }         // End if block

        speed = gameObject.rigidbody2D.velocity.magnitude;
    }     // End Update()
예제 #24
0
    void setInput(int id, int num)
    {
        if (id < 0 || id >= 6)
        {
            return;
        }

        UILabel label = inputs[id];

        if (num >= 0 && num < 10)
        {
            label.text = "" + num;
        }
        else
        {
            label.text = "";
        }

        label.MakePixelPerfect();
    }
예제 #25
0
    public static GameObject CreateUITextureButton_NULL(
        GameObject panel,
        string text    = null,
        UIFont font    = null,
        float fontSize = 16
        )
    {
        // refer to CreateButton at UICreateWidgetWizard

        int depth = NGUITools.CalculateNextDepth(panel);
        var go    = NGUITools.AddChild(panel);

        go.name = "Button";

        var bg = NGUITools.AddWidget <UITexture>(go);

        bg.name  = "Background";
        bg.depth = depth;

        if (text != null)
        {
            UILabel lbl = NGUITools.AddWidget <UILabel>(go);
            lbl.font = font;
            lbl.text = go.name;
            lbl.MakePixelPerfect();
        }

        // Add a collider
        NGUITools.AddWidgetCollider(go);

        // Add the scripts
        go.AddComponent <UIButton>().tweenTarget = bg.gameObject;
        go.AddComponent <UIButtonScale>();
        //go.AddComponent<UIButtonOffset>();
        go.AddComponent <UIButtonSound>();
        var ubm = go.AddComponent <UIButtonMessage>();

        ubm.target       = panel.GetComponentInChildren <xmlTags_html>().gameObject;
        ubm.functionName = "OnButtonClick";
        return(go);
    }
예제 #26
0
    /// <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.MakePixelPerfect();
            }

            // Add a collider
            NGUITools.AddWidgetCollider(go);

            // Add the scripts
            go.AddComponent <UIButton>().tweenTarget = bg.gameObject;
            go.AddComponent <UIPlaySound>();

            Selection.activeGameObject = go;
        }
    }
예제 #27
0
    public void SetData(int index)
    {
        gameObject.name = index.ToString();

//        rangeStart = 10*index + 1;
        rangeEnd = 10 * index + 10;

        Tab_BiographyItem itemTab = TableManager.GetBiographyItemByID(index, 0);

        int contentLbHeight = 0;

        if (itemTab != null)
        {
            m_LevelRangeName.text    = StrDictionary.GetClientString_WithNameSex(itemTab.Name);
            m_LevelRangeContent.text = StrDictionary.GetClientString_WithNameSex(itemTab.Content);

            // contentBkSp

            m_LevelRangeContent.MakePixelPerfect();

            contentLbHeight = m_ContentBackSp.height + itemTab.AddBackHeigh;

            m_ContentBackSp.height = contentLbHeight;

            // icon position

            m_ContentIconSp.spriteName = itemTab.SpriteIconName;

            m_ContentIconSp.MakePixelPerfect();

            float IconPosition_y = m_ContentBackSp.gameObject.transform.localPosition.y + itemTab.AddBackHeigh + 100;

            m_ContentIconSp.gameObject.transform.localPosition = new Vector3(m_ContentIconSp.gameObject.transform.localPosition.x, IconPosition_y, 0f);


            SetAlreadyReachSp(itemTab.BeginLevel, itemTab.EndLevel);
        }

        //if (m_LevelRangeName != null)
        //m_LevelRangeName.text = rangeStart.ToString() + " 级到 " +rangeEnd.ToString() + " 级";
    }
예제 #28
0
    void ShowCombo(bool show)
    {
        if (show)
        {
            _comboPanel.enabled = true;
            _comboPanel.text    = CurrentCount.ToString();
            _comboPanel.MakePixelPerfect();
            _comboPanelScale = _comboPanelTransform.localScale;
            _comboPanelTransform.localScale = _comboPanelScale * _startScale;

            _mySprite.enabled = true;
            _mySprite.MakePixelPerfect();
            _comboBackgroundScale = _comboBackgroundTransform.localScale;
            _comboBackgroundTransform.localScale = _comboBackgroundScale * _startScale;
        }
        else
        {
            _comboPanel.enabled = false;
            _mySprite.enabled   = false;
        }
    }
예제 #29
0
파일: UIUtil.cs 프로젝트: atom-chen/tianyu
    private static UILabel CreateLabel(GameObject parent, string str, UIFont mFont, string color)
    {
        int     nextDepth = NGUITools.CalculateNextDepth(parent);
        UILabel lbl       = NGUITools.AddWidget <UILabel>(parent);

        lbl.name                 = "Label_text";
        lbl.depth                = nextDepth;
        lbl.bitmapFont           = mFont;
        lbl.pivot                = UILabel.Pivot.TopLeft;
        lbl.transform.localScale = new Vector3(mFont.defaultSize, mFont.defaultSize, 1f);
        lbl.MakePixelPerfect();
        lbl.supportEncoding = true;
        lbl.symbolStyle     = NGUIText.SymbolStyle.Normal;

        if (color != null)
        {
            lbl.color = ColorManage.GetColor(color);
        }
        lbl.text = str;
        return(lbl);
    }
예제 #30
0
        /// <summary>
        /// Setup the script
        /// </summary>
        public void Setup(UIFont font)
        {
            // Setup base properties
            GameObject parent   = Display.topRight;
            string     name     = "FpsCounter";
            Vector3    position = new Vector3(-15f, -15f, 0f);

            base.Setup(parent, name, position);

            // Add label
            _label             = this.gameObject.AddComponent <UILabel>();
            _label.font        = font;
            _label.text        = "XX.X FPS";
            _label.pivot       = UIWidget.Pivot.TopRight;
            _label.effectStyle = UILabel.Effect.Outline;
            _label.MakePixelPerfect();

            // Setup counter
            _counter = new FpsCounter(0.5f);
            _counter.Reset();
        }
예제 #31
0
	protected override bool DrawProperties ()
	{
		mLabel = mWidget as UILabel;
		ComponentSelector.Draw<UIFont>(mLabel.font, OnSelectFont);

		if (mLabel.font != null)
		{
			GUI.skin.textArea.wordWrap = true;
			string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text;
			text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f));
			if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; }

			GUILayout.BeginHorizontal();
			int len = EditorGUILayout.IntField("Max Width", mLabel.lineWidth, GUILayout.Width(120f));
			GUILayout.Label("pixels");
			GUILayout.EndHorizontal();
			if (len != mLabel.lineWidth) { RegisterUndo(); mLabel.lineWidth = len; }

			int count = EditorGUILayout.IntField("Max Lines", mLabel.maxLineCount, GUILayout.Width(100f));
			if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; }

			GUILayout.BeginHorizontal();
			bool shrinkToFit = EditorGUILayout.Toggle("Shrink to Fit", mLabel.shrinkToFit, GUILayout.Width(100f));
			GUILayout.Label("- adjust scale to fit");
			GUILayout.EndHorizontal();
			
			if (shrinkToFit != mLabel.shrinkToFit)
			{
				RegisterUndo();
				mLabel.shrinkToFit = shrinkToFit;
				if (!shrinkToFit) mLabel.MakePixelPerfect();
			}

			GUILayout.BeginHorizontal();
			bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(100f));
			GUILayout.Label("- hide characters");
			GUILayout.EndHorizontal();
			if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; }

			GUILayout.BeginHorizontal();
			bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f));
			GUILayout.Label("- use emoticons and colors");
			GUILayout.EndHorizontal();
			if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; }

			//GUILayout.EndHorizontal();

			if (encoding && mLabel.font.hasSymbols)
			{
				UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f));
				if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; }
			}

			GUILayout.BeginHorizontal();
			{
				UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f));
				if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; }

				if (effect != UILabel.Effect.None)
				{
					Color c = EditorGUILayout.ColorField(mLabel.effectColor);
					if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; }
				}
			}
			GUILayout.EndHorizontal();

			if (mLabel.effectStyle != UILabel.Effect.None)
			{
				GUILayout.Label("Distance", GUILayout.Width(70f));
				GUILayout.Space(-34f);
				GUILayout.BeginHorizontal();
				GUILayout.Space(70f);
				Vector2 offset = EditorGUILayout.Vector2Field("", mLabel.effectDistance);
				GUILayout.Space(20f);

				if (offset != mLabel.effectDistance)
				{
					RegisterUndo();
					mLabel.effectDistance = offset;
				}
				GUILayout.EndHorizontal();
			}
			return true;
		}
		EditorGUILayout.Space();
		return false;
	}
예제 #32
0
    void Awake()
    {
        label = gameObject.GetComponent<UILabel>();
        line = VectorLine.SetLine (Color.gray, Vector2.zero, Vector2.zero);

        active = false;
        label.MakePixelPerfect();
    }