직렬화는 데이터 구조 또는 오브젝트 상태를 Unity가 보관하고 나중에 다시 복구할 수 있는 포맷으로 변환하는 자동 프로세스입니다. 자세한 내용은 스크립트 직렬화를 참조하십시오.
특정 상황에서 스크립트 직렬화가 오류를 일으킬 수 있습니다. 아래에서 이러한 문제에 대한 해결 방법을 볼 수 있습니다.
MonoBehaviour 생성자 또는 필드 이니셜라이저에서 GameObject.Find 같은 스크립팅 API를 호출하면 “Find is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call in Awake or Start instead.”와 같은 오류가 발생합니다.
생성자 대신 MonoBehaviour.Start에서 스크립팅 API를 호출하면 이 문제를 해결할 수 있습니다.
System.Serializable
표시된 클래스의 생성자에서 GameObject.Find 같은 스크립팅 API를 호출하면 “Find is not allowed to be called during serialization, call it from Awake or Start instead.”와 같은 오류가 발생합니다.
직렬화된 오브젝트의 생성자에서 스크립팅 API를 호출하지 않도록 코드를 편집해 이 문제를 해결할 수 있습니다.
대부분의 스크립팅 API는 위에서 언급한 제약 사항의 영향을 받습니다. 다음과 같은 일부 Unity 스크립팅 API만 제외되며 어디서나 호출될 수 있습니다.
Mathf 함수
예를 들어, Vector3 및 Quaternion 수학 구조체와 같은 단순한 독립 구조체
직렬화 중 오류 가능성을 낮추기 위해서는 독립적인 구조이면서 Unity 자체에서 데이터를 가져오거나 설정할 필요가 없는 API 메서드만 호출합니다. 대안책이 없는 경우에만 호출합니다.
• 2017–05–15 편집 리뷰를 거쳐 페이지 게시됨
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.