Programing/Unity
Unity Error CS0246
Ezzi
2017. 11. 8. 18:18
반응형
CS0246은 빌드 타임시 나는 에러이다.
다음과 같이 해결할 수 있다.
#if UNITY_EDITOR
// Unity Editord에서 사용할 코드
#else
// 런타임 시에 사용할 코드
#endif
ex) 예제 코드
#if UNITY_EDITOR using UnityEditor; // UnityEditor namespace도 에러가 나게 된다. #endif #if UNITY_EDITOR namespace MyNameSpace { [CustomEditor(typeof(someClass))] public class MyCustomInspector : Editor { // Custom Editor를 만들기 위해 Editor를 상속받게 되면 빌드타임시 CS0246 에러가 나게 된다. // 다음과 같이 #if #endif 로 막아주면 에러가 사라진다. } } #endif |
반응형