標籤:style blog http color os 2014
using UnityEngine;using System.Collections;public class GUITest : MonoBehaviour { public GUISkin myGUISking; private Rect windowRect; private Vector2 scrollPosition; string info=" 測試測試測試測試測試測試測試測試測試測試 \n " + "測試測試測試測試測試測試測試測試\n測試測試測試測試測試測試\n測試測試測試測試測試測試測試測試\n測試測試測試測試測試測試測試測試\n" + "測試測試測試測試測試測試測試測試測試測試\n測試測試測試測試測試測試測試測試\n測試測試測試測試測試測試"; // Use this for initialization void Start () { windowRect = new Rect (500,140,350,510); } // Update is called once per frame void Update () { } void OnGUI(){ GUI.skin = myGUISking; windowRect = GUI.Window (0,windowRect,DoMyWindow,""); } void DoMyWindow( int windowID){ GUILayout.BeginVertical (); GUILayout.Space (8); GUILayout.Button ("", "MyButtonSkin"); GUILayout.Space (8); GUILayout.Label ("","MyDividerSkin"); GUILayout.Label ("MyLabelSkin","MyLabelSkin"); GUILayout.Label ("","MyDividerSkin"); GUILayout.Label ("","MyDividerSkin"); GUILayout.Label ("","MyDividerSkin"); GUILayout.Label ("","MyDividerSkin"); GUILayout.BeginHorizontal (); scrollPosition = GUILayout.BeginScrollView (scrollPosition, false, true); GUILayout.Label (info,"MyTextSkin"); GUILayout.EndScrollView (); GUILayout.EndHorizontal (); GUILayout.EndVertical (); GUI.DragWindow (new Rect(0,0,10000,10000)); }}
GUI原理很簡單,和flash組件差不多,只能unity3d中是可視化編輯,調整各種屬性,然後即可得到視圖效果。