테스트에 용이한 OnGUI 모든것






GUIManager.cs 소스입니다




using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GUIManager : MonoBehaviour
{
public Vector3 matrixPos;
public float matrixScale;
public GUISkin CustomGUISkin;

public Texture2D controlTexture;
public string textFieldString;
public bool toggleBool = true;
public int toolbarInt = 0;
public string[] toolbarStrings = { "Toolbar1", "Toolbar2", "Toolbar3" };
public int selectionGridInt = 0;
public string[] selectionStrings = { "Grid 1", "Grid 2", "Grid 3", "Grid 4", "Grid 5" };
public float hSliderValue;
public float vSliderValue;
public float hScrollbarValue;
public float vScrollbarValue;
public Vector2 scrollViewVector;
public string innerText;



void OnGUI()
{
#if (!UNITY_EDITOR)
return;
#endif

GUI.matrix = Matrix4x4.TRS(matrixPos, Quaternion.identity, Vector3.one * matrixScale);
GUI.skin = CustomGUISkin;


if (GUI.Button(new Rect(0, 0, Screen.width, Screen.height), "Level 1"))
{

}

GUI.Box(new Rect(10, 10, 300, 300), "Loader Menu");
GUI.Label(new Rect(0, 0, 100, 50), "This is the text string for a Label Control");

GUI.Box(new Rect(10, 10, 200, 100), new GUIContent("This is text", controlTexture));

GUI.Button(new Rect(10, 10, 100, 20), new GUIContent("Click me", "This is the tooltip"));
GUI.Label(new Rect(10, 40, 100, 20), GUI.tooltip);

if (GUI.RepeatButton(new Rect(25, 25, 100, 30), "RepeatButton"))
{

}

textFieldString = GUI.TextField(new Rect(25, 25, 100, 30), textFieldString);
textFieldString = GUI.TextArea(new Rect(25, 25, 100, 30), textFieldString);

toggleBool = GUI.Toggle(new Rect(25, 25, 100, 30), toggleBool, "Toggle");

toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);

selectionGridInt = GUI.SelectionGrid(new Rect(25, 25, 200, 60), selectionGridInt, selectionStrings, 2);

hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0f, 10.0f);
vSliderValue = GUI.VerticalSlider(new Rect(25, 25, 100, 30), vSliderValue, 10.0f, 0.0f);

hScrollbarValue = GUI.HorizontalScrollbar(new Rect(25, 25, 100, 30), hScrollbarValue, 1.0f, 0.0f, 10.0f);
vScrollbarValue = GUI.VerticalScrollbar(new Rect(25, 25, 100, 30), vScrollbarValue, 1.0f, 10.0f, 0.0f);

scrollViewVector = GUI.BeginScrollView(new Rect(25, 25, 100, 100), scrollViewVector, new Rect(0, 0, 400, 400));
innerText = GUI.TextArea(new Rect(0, 0, 400, 200), innerText);
innerText = GUI.TextField(new Rect(0, 200, 400, 200), innerText);
GUI.EndScrollView();

Rect windowRect = new Rect(20, 20, 300, 300);
windowRect = GUI.Window(0, windowRect, WindowFunction, "My Window");

if (GUI.changed)
{

}
}


void WindowFunction(int windowID)
{

}
}