Warning: Undefined array key "REMOTE_USER" in /kieuns/www/lib/plugins/googleanalytics/action.php on line 61 basic template [GINS WIKI 긴스 위키] Warning: Undefined array key "stylesheets" in /kieuns/www/inc/StyleUtils.php on line 102

사용자 도구

사이트 도구


language:unity:6-inspector
Warning: Trying to access array offset on value of type bool in /kieuns/www/inc/html.php on line 1164 Warning: Trying to access array offset on value of type bool in /kieuns/www/inc/html.php on line 1168 Warning: Trying to access array offset on value of type bool in /kieuns/www/inc/html.php on line 1171 Warning: Trying to access array offset on value of type bool in /kieuns/www/inc/html.php on line 1172

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
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 형식상 원래 클래스 이름에 'Editor'를 붙이는 듯
 +public class TestClassEditor : Editor
 +{
 +  // 인스펙터에 요소들을 표시하는 방법을 코딩한다.
 +  public override void OnInspectorGUI()
 +  {
 +    // 이 인스펙터에 대응되는 타켓 스크립트
 +    TestClass test_class = target as TestClass;
 +  }
 +}
 +</code>
 +
 +클래스 이름은 "%%<Target Class>%%Editor" or "%%<Target Class>%%Inspector" 아무거나 선택.
 +
 +  * 레퍼런스
 +    * [[http://docs.unity3d.com/Documentation/ScriptReference/Editor.html]]
 +    * [[http://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.html]]
 +    * [[http://docs.unity3d.com/Documentation/ScriptReference/EditorUtility.html]]
 +
 +편하게, 도움을 주는
 +
 +  * NGUI 플러그인을 사용하는 것이면 : NGUIEditorTools 클래스가 도움이 된다.
 +
 +아직 모르는 개념들
 +
 +  * SerializedProperty;
 +
 +====== 메소드 몇개 ======
 +
 +  * [[http://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.EnumPopup.html|EditorGUILayout.EnumPopup]]
 +  * [[http://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.ObjectField.html|EditorGUILayout.ObjectField]]
 +
 +====== Button 과 같은 이벤트 리시버를 인스펙터에 추가 ======
 +
 +UnityEvent 로 public 변수를 선언하면 알맞게 표시된다.
 +
 +<code csharp>
 +using UnityEngine.Events;
 +public class SampleClass : MonoBehaviour {
 +  public UnityEvent onMoveFowardDone;
 +  public UnityEvent onMoveBackwardDone;
 +}
 +</code>
 +
 +====== 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(".prefab", "");
 + atlasName = atlasName.Substring(prefabPath.LastIndexOfAny(new char[] { '/', '\\' }) + 1);
 + go = new GameObject(atlasName);
 + go.AddComponent<UIAtlas>().spriteMaterial = mat;
 +
 + // Update the prefab
 + PrefabUtility.ReplacePrefab(go, prefab);
 + DestroyImmediate(go);
 + AssetDatabase.SaveAssets();
 + AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
 +</code>
 +
 +
 +===== 형식 =====
 +
 +<code>
 +using UnityEngine;
 +using UnityEditor;
 +
 +// 에디터 이름
 +public class UIAtlasMaker : EditorWindow
 +{
 +}
 +</code>