유니티 - Editor Folder

Unity 2019. 8. 4. 15:38
728x90

1장 에디터 확장에 사용하는 폴더
1.1 Editor 폴더

Editor폴더는 에디터 API를 사용하기 위한 특별한 폴더.
보통 에디터 API는, 런타임으로 동작하지 않음.

아래 코드를 Assets 폴더 바로 아래에 작성해서 빌드해보면 빌드 실패 뜸.

using UnityEngine;
using UnityEditor;

public class NewBehaviourScript : MonoBehaviour
{
}

개발 중의 유니티 에디터 상에서 생성되는 Assembly-CSharp.dll에서는 UnityEditor.dll에의 참조가 발생하므로 스크립트의 컴파일 에러는 발생하지 않음.
빌드 시에 생성되는 Assembly-CSharp.dll에서는  UnityEditor.dll에의 참조가 발생하지 않기 때문에 빌드 에러가 발생하는것. 중요. 이거 몰라서 빌드 에러 원인 못찾고 그럼.

UnityEditor에서는 Assembly-CSharp-Editor.dll을 생성해서, 에디터 API와 런타임 API를 구분하는 것으로 문제를 해결함. Assembly-CSharp-Editor.dll는 빌드 시에는 포함되지 않으므로 빌드 에러도 발생 안함. 

그리고 Assembly-CSharp-Editor.dll은 Editor 폴더 안의 스크립트 파일이 컴파일 되어 생성되는것.

Editor 폴더의 생성장소는 별 제한 없음. 여러개의 Editor 폴더를 생성할수도 있음.
단, Standard Assets, Pro Standard Assets, Plugins 폴더 안에 생성하면 그 안의 스크립트는
Assembly-CSharp-Editor-firstpass.dll에 컴파일됨.

Assembly-CSharp-Editor.dll에서 firstpass를 참조할수는 있지만
firstpass에서 Assembly-CSharp-Editor.dll를 참조할수는 없음. 주의.

[Editor 폴더에 포함 안시키고 동작시키는 방법]

런타임에서 동작하는 스크립트에 에디터 API 꺼를 사용하는 겨우가 있음. 이 경우에는 아래와같이 처리할것.

using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class NewBehaviourScript : MonoBehaviour
{
    void OnEnable ()
    {
        #if UNITY_EDITOR
        EditorWindow.GetWindow<ExampleWindow> ();
        #endif
    }
}

1.2 Editor Default Resources 폴더
Resources 폴더랑 마찬가지로 에디터 확장에서만 사용할 리소스를 넣어둘 수 있는 폴더임.
Editor Default Resources 폴더 안에 있는 에셋은 EditorGUIUtility.Load로 접근 가능.

var tex = EditorGUIUtility.Load ("logo.png") as Texture;

https://blog.naver.com/PostView.nhn?blogId=hammerimpact&logNo=220769879313&parentCategoryNo=&categoryNo=19&viewDate=&isShowPopularPosts=false&from=postView

728x90

'Unity' 카테고리의 다른 글

유니티 - 충돌 (Trigger, Collider)  (0) 2019.08.07
유니티 - 에디터 확장 기능  (0) 2019.08.05
유니티 - PropertyDrawer  (0) 2019.08.03
유니티 - ScriptableObject  (0) 2019.08.02
유니티 에디터 - MenuItem  (0) 2019.08.01
Posted by 정망스
,


맨 위로
홈으로 ▲위로 ▼아래로 ♥댓글쓰기 새로고침