2014年4月28日月曜日

unityでWizardEditorを作る方法

unityでWizardEditorを作る方法
Assetsの中にEditorフォルダを作り中にScriptableWizardを継承したEditorを作ればいいっぽい

using UnityEngine;
using System.Collections;
using UnityEditor;

public class ExWinzard : ScriptableWizard
{
 public float range = 500;
 public Color color = Color.red;

 [MenuItem("Window/ExWinzard")]
 static void init()
 {
  ExWinzard window = (ExWinzard)EditorWindow.GetWindow(typeof(ExWinzard));
 }

 void OnWizardCreate()
 {
  GameObject go = new GameObject("New Light");
  go.AddComponent("Light");
  go.light.range = range;
  go.light.color = color;
 }

 void OnWizardUpdate()
 {
  helpString = "Please set the color of the light!";
 }

 void OnWizardOtherButton()
 {
  if (Selection.activeTransform == null ||
    Selection.activeTransform.light == null) return;
  Selection.activeTransform.light.color = Color.red;
 }

}

OnWizardCreateがCreateを押された時の処理
OnWizardUpdateの中でヘルプを書くっぽい

0 件のコメント: