Warning: Undefined array key "REMOTE_USER" in /kieuns/www/lib/plugins/googleanalytics/action.php on line 61
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
language:unity:6-inspector [2014/01/18 15:28] kieuns |
language:unity:6-inspector [2024/04/23 22:44] (현재) |
||
---|---|---|---|
줄 1: | 줄 1: | ||
+ | ====== basic template ====== | ||
+ | |||
+ | * 에디터용 네임스페이스 추가 | ||
+ | * CustomEditor 속성 추가 | ||
+ | * Editor에서 상속되는 클래스 | ||
+ | * OnInspectorGUI() 오버라이드 함수 | ||
+ | |||
+ | <code csharp> | ||
+ | // | ||
+ | // TestClass 에 대한 커스텀 인스펙터를 정의하는 예 | ||
+ | // | ||
+ | |||
+ | // 포함해야할 using | ||
+ | using UnityEngine; | ||
+ | using UnityEditor; | ||
+ | |||
+ | // CustomEditor : 어떤 클래스에 대응 되는 인스펙터인가 | ||
+ | [CustomEditor(typeof(TestClass))] | ||
+ | // TestClassEditor : [ClassName]Editor 형식상 원래 클래스 이름에 ' | ||
+ | public class TestClassEditor : Editor | ||
+ | { | ||
+ | // 인스펙터에 요소들을 표시하는 방법을 코딩한다. | ||
+ | public override void OnInspectorGUI() | ||
+ | { | ||
+ | // 이 인스펙터에 대응되는 타켓 스크립트 | ||
+ | TestClass test_class = target as TestClass; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 클래스 이름은 " | ||
+ | |||
+ | * 레퍼런스 | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | 편하게, 도움을 주는 | ||
+ | |||
+ | * NGUI 플러그인을 사용하는 것이면 : NGUIEditorTools 클래스가 도움이 된다. | ||
+ | |||
+ | 아직 모르는 개념들 | ||
+ | |||
+ | * SerializedProperty; | ||
+ | |||
+ | ====== 메소드 몇개 ====== | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | ====== Button 과 같은 이벤트 리시버를 인스펙터에 추가 ====== | ||
+ | |||
+ | UnityEvent 로 public 변수를 선언하면 알맞게 표시된다. | ||
+ | |||
+ | <code csharp> | ||
+ | using UnityEngine.Events; | ||
+ | public class SampleClass : MonoBehaviour { | ||
+ | public UnityEvent onMoveFowardDone; | ||
+ | public UnityEvent onMoveBackwardDone; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====== Prefab 생성하는 에디터 ====== | ||
+ | |||
+ | <code csharp> | ||
+ | // Create a new prefab for the atlas | ||
+ | Object prefab = (go != null) ? go : PrefabUtility.CreateEmptyPrefab(prefabPath); | ||
+ | |||
+ | // Create a new game object for the atlas | ||
+ | string atlasName = prefabPath.Replace(" | ||
+ | atlasName = atlasName.Substring(prefabPath.LastIndexOfAny(new char[] { '/', | ||
+ | go = new GameObject(atlasName); | ||
+ | go.AddComponent< | ||
+ | |||
+ | // Update the prefab | ||
+ | PrefabUtility.ReplacePrefab(go, | ||
+ | DestroyImmediate(go); | ||
+ | AssetDatabase.SaveAssets(); | ||
+ | AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 형식 ===== | ||
+ | |||
+ | < | ||
+ | using UnityEngine; | ||
+ | using UnityEditor; | ||
+ | |||
+ | // 에디터 이름 | ||
+ | public class UIAtlasMaker : EditorWindow | ||
+ | { | ||
+ | } | ||
+ | </ |