제목과 같은 상황에서는 C# 전처리기 지시문과 함께 유니티 플랫폼 #define 지시어를 사용해 처리할 수 있다.
꼭 PC, android, ios 같은 플랫폼 뿐만 아니라 유니티 editor에서 사용할 수 있는 지시어도 있다.
활용 예시
#if UNITY_EDITOR
using UnityEditor;
#endif
...
public void Exit()
{
#if UNITY_EDITOR
//에디터 환경에서는 playmode를 종료
EditorApplication.ExitPlaymode();
#else
//빌드 환경에서는 어플리케이션 자체를 종료
Application.Quit();
#endif
}
C# 전처리기 지시문
https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/preprocessor-directives
유니티 플랫폼 #define 지시어
https://docs.unity3d.com/kr/current/Manual/PlatformDependentCompilation.html