简体   繁体   English

在Unity中的“ OnAfterDeserialize”之前是否有一个被调用的类或函数?

[英]Is there a class or function called right before 'OnAfterDeserialize' in Unity?

I define my class with ISerializationCallbackReceiver in ScriptableObject, and write my serialized code in OnAfterDeserialize . 我在ScriptableObject中使用ISerializationCallbackReceiver定义了我的类,并在OnAfterDeserialize编写了序列化的代码。 My problem is I need to do some environment preparing before OnAfterDeserialize, but ISerializationCallbackReceiver will call when unity startup. 我的问题是我需要在OnAfterDeserialize之前做一些环境准备,但是当统一启动时ISerializationCallbackReceiver会调用。

Is there a class or function called right before ISerializationCallbackReceiver so I can add my code before unity begins to serialize ScriptableObject . ISerializationCallbackReceiver之前是否有一个被调用的类或函数,因此我可以在统一开始序列化ScriptableObject之前添加代码。 I've already tried the RuntimeInitializeOnLoadMethod Attribute but it is called after ISerializationCallbackReceiver . 我已经尝试过RuntimeInitializeOnLoadMethod属性,但是在ISerializationCallbackReceiver之后调用它。

Is there a class or function called right before ISerializationCallbackReceiver so I can add my code before unity begins to serialize ScriptableObject. 在ISerializationCallbackReceiver之前是否存在一个被调用的类或函数,因此我可以在统一开始序列化ScriptableObject之前添加代码。

The ISerializationCallbackReceiver interface has two functions which are OnBeforeSerialize and OnAfterDeserialize . ISerializationCallbackReceiver接口具有两个函数OnBeforeSerializeOnAfterDeserialize

You can use the OnBeforeSerialize function to add your code because it will be called before Unity serializes your object 您可以使用OnBeforeSerialize函数添加代码,因为它将在Unity序列化对象之前被调用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM