2014年4月21日月曜日

Unityで編集中もGUIを表示する方法

[ExecuteInEditMode()]
をクラスの属性に付けておく。
こんな感じ。



using UnityEngine;
using System.Collections;

[ExecuteInEditMode()]
public class GUIButton : MonoBehaviour {

 // Use this for initialization
 void Start ()
 {
 
 }
 
 // Update is called once per frame
 void Update ()
 {
 
 }

 void OnGUI()
 {
  if (GUI.Button(new Rect(10, 10, 200, 20), "Button"))
  {
   //クリック時
  }
 }
}

すると編集中にもボタンが現れる。

0 件のコメント: