빌드하다가 오류가 발생하여 작성하는 TIL
나타난 오류는 다음과 같다
The type or namespace name 'Animations' does not exist in the namespace 'UnityEditor'"
UnityEditor는 빌드버전에서는 사용할 수 없다.
해당 기능을 사용할 수 없기때문에 다른 대체 방법을 찾아야 한다.
Animations의 경우에는 비교적 간단하다.
기존에 쓰던 방식은 다음과 같다
public AnimatorController[] DragonAnimators;
여기서 AnimatorController는 UnityEditor.Animations에서 필요로 하는 변수이다.
이를 다음으로 바꾸어주면 된다
public RuntimeAnimatorController[] DragonAnimators;
이 외에 unityeditor를 쓰는 경우는 다음이 있다.
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
이건 #if를 통해 예외처리를 해 주었기 때문에 가능하다.
저런 방식은 여러 플랫폼에서 어떻게 행동할지 정해줄수 있기도 하다. 후에 안드로이드, 아이폰으로도 제작하는 경우 여러가지 행동을 넣어줄 수 있다.
쉽게 변경할 수 있어서 다행이다..