2. Unity3d 에디터 확장
에디터 확장
- 유니티3D의 메뉴, 윈도우의 확장, 수정이 가능
- GUI, 몬스터, 스테이지 생성 등의 개발 시 효율적
3. Unity3d 에디터 확장
에디터를 확장하기 위해선?
- 문서 : Scripting Reference의 Editor Classes
- Project 폴더의 Asset/Editor 폴더내에 스크립트 작성
- 스크립트 내에 using UnityEditor; 추가
4. Unity3d 에디터 확장
sample1
public override void OnInspectorGUI() {
Movement.cs
public class Movement : MonoBehaviour { EditorGUILayout.BeginHorizontal();
public int speed; string[] speedNames = new string[]
public Vector3 targetPosition; { "slow", "normal", "fast", "fastest" };
}
int[] speedValues = new int[] { 1, 5, 10, 20 };
movement.speed
MovementEditor.cs
using UnityEngine; = EditorGUILayout.IntPopup(
using UnityEditor; movement.speed, speedNames, speedValues);
using System.Collections; EditorGUILayout.EndHorizontal();
movement.targetPosition
[CustomEditor(typeof(Movement))] = EditorGUILayout.Vector3Field(
public class MovementEditor : Editor { "Target Position", movement.targetPosition);
Movement movement;
void OnEnable() { if (GUI.changed)
movement = target as Movement; EditorUtility.SetDirty(target);
} }
}
5. Unity3d 에디터 확장
sample2
MakeSimpleImage.cs
SimpleImage.cs using UnityEngine;
public class SimpleImage : MonoBehaviour {
using UnityEditor;
Texture2D siTexture;
void Start() {
public class MakeSimpleImage : EditorWindow {
}
}
[MenuItem(
"GameObject/Custom Object/SimpleImage")]
static void CreateSimpleImage () {
GameObject gameObject
= new GameObject("SimpleImage");
gameObject.AddComponent<SimpleImage>();
}
}