IL2CPP 런타임 코드 확인
null 레퍼런스 및 바운드 외 검사와 같은 런타임 안전 기능을 포함하거나 비활성화하도록 IL2CPP의 C++ 생성을 구성합니다.
읽는 시간 2분최근 업데이트: 9일 전
[Il2CppSetOption]Option[Il2CppSetOption][Il2CppSetOption]- Unity 버전이 설치된 디렉토리에서 Windows의 경우 디렉토리 또는 macOS의 경우
Data\il2cpp디렉토리로 이동합니다.Contents/Frameworks/il2cpp - 소스 파일을 찾습니다.
Il2CppSetOptionAttribute.cs - 소스 파일을 프로젝트의 폴더에 복사합니다.
Assets
속성에 대해 지원되는 옵션은 다음과 같습니다.
프로퍼티 | 설명 | Default |
|---|---|---|
| Null 체크 | 이 옵션을 활성화한 상태로 유지하는 것이 좋습니다. 비활성화하면 IL2CPP는 null 확인 없이 C++를 생성하며 관리되는 | 활성화됨 |
| 어레이 경계 확인 | 이 옵션을 활성화한 상태로 유지하는 것이 좋습니다. 비활성화하면 IL2CPP는 배열 바운드 확인 없이 C++를 생성하며 관리되는 | 활성화됨 |
| 검사 0으로 나누기 | 0 체크표로 나누기를 실행해야 하는 경우를 제외하고 이 옵션을 비활성화 상태로 유지합니다. 활성화하면 IL2CPP는 정수 분할에 대해 0으로 나누기 확인이 포함된 C++를 생성하고 필요한 경우 관리되는 이러한 확인은 런타임 시 성능에 영향을 미칩니다. | Disabled |
다음 예시는 속성을 사용하는 방법을 보여 줍니다.
[Il2CppSetOption][Il2CppSetOption(Option.NullChecks, false)]public static string MethodWithNullChecksDisabled(){ var tmp = new object(); return tmp.ToString();}
어셈블리, 타입, 메서드 및 프로퍼티에 를 적용할 수 있습니다. Unity 가장 로컬 범위의 속성을 사용합니다.
[Il2CppSetOption][Il2CppSetOption(Option.NullChecks, false)]public class TypeWithNullChecksDisabled{ public static string AnyMethod() { // Unity doesn’t perform null checks in this method. var tmp = new object(); return tmp.ToString(); } [Il2CppSetOption(Option.NullChecks, true)] public static string MethodWithNullChecksEnabled() { // Unity performs null checks in this method. var tmp = new object(); return tmp.ToString(); }}public class SomeType{ [Il2CppSetOption(Option.NullChecks, false)] public string PropertyWithNullChecksDisabled { "GET", { // Unity doesn't perform null checks here. var tmp = new object(); return tmp.ToString(); } 세트 { // Unity doesn't perform null checks here. value.ToString(); } } public string PropertyWithNullChecksDisabledOnGetterOnly { [Il2CppSetOption(Option.NullChecks, false)] "GET", { // Unity doesn’t perform null checks here. var tmp = new object(); return tmp.ToString(); } 세트 { // Unity performs null checks here. value.ToString(); } }}