UnityEngine.GUIStyle.CalcSize C# (CSharp) Method

CalcSize() public method

Calculate the size of some content if it is rendered with this style.

public CalcSize ( GUIContent content ) : Vector2
content GUIContent
return Vector2
        public Vector2 CalcSize(GUIContent content)
        {
            Vector2 vector;
            Internal_CalcSize(this.m_Ptr, content, out vector);
            return vector;
        }

Usage Example

コード例 #1
0
ファイル: GameStart.cs プロジェクト: pmlamotte/2Pac
    void OnGUI()
    {
        if (showStartingScreen) {
            int height = (int)(Screen.height * .2f);
            GUI.Box(new Rect(0, Screen.height / 2 - height / 2, Screen.width, height),"");

            GUIContent text = new GUIContent("" + ((num == 0) ? "GO" : num + ""));

            GUIStyle watStyle = new GUIStyle(textStyle);
            int x = 0;
            if (currTime < .2f) {
                x = (int)(currTime / .2f * Screen.width / 2 - watStyle.CalcSize(text).x / 2);
            } else if (currTime >= .2f && currTime <= .8f) {
                watStyle.fontSize += (int)(20 - 20*((Mathf.Abs(.5f - currTime))/.3f));
                x = (int)(Screen.width / 2 - watStyle.CalcSize(text).x / 2);
            } else if (currTime > .8f) {
                x = (int)((currTime - .8f) / .2f * Screen.width/2 - watStyle.CalcSize(text).x / 2 + Screen.width /2);
            }
            GUI.Label(new Rect(x, Screen.height / 2 - watStyle.CalcSize(text).y / 2, 100, 100),text, watStyle);

            currTime += Time.realtimeSinceStartup - lastTime;
            lastTime = Time.realtimeSinceStartup;
            if (currTime >= 1f) {
                currTime = 0f;
                num--;
            }

            if (num < 0) {
                showStartingScreen = false;
                Time.timeScale = 1;
            }
        }
    }
All Usage Examples Of UnityEngine.GUIStyle::CalcSize