Unity/Function
Unity에서 플랫폼 별 코드 실행: Application.platform vs #if 디렉티브
Unity 개발 시 다양한 플랫폼을 지원하기 위해 플랫폼 별로 다른 코드 실행이 필요할 때가 있습니다. 이를 위한 주요 두 가지 방법, Application.platform과 #if 디렉티브를 비교해 보겠습니다. Application.platform의 사용 Application.platform은 Unity의 런타임 시점에서 현재 실행 중인 플랫폼을 확인하는 방법입니다. 장점 동적 처리: 단일 빌드로 여러 플랫폼에서 다르게 동작하는 앱을 만들 수 있습니다. 코드 포함: 빌드에 모든 플랫폼에 대한 코드가 포함되어, 하나의 빌드로 여러 환경을 대응할 수 있습니다. 사용 예 if (Application.platform == RuntimePlatform.WindowsPlayer) { // Windows 전용 코드..