Unity的redis 序列化配置表问题用什么方法比较好

关注游戏葡萄
微信扫描二维码关注
游戏葡萄公众号
的其他文章
的其他文章
的其他文章
的其他文章
的其他文章
的其他文章
TalkingData
的其他文章
的其他文章
的其他文章
All Rights Reserved
赞助Sponsor
赞助Sponsor
阅读Articles
数据库Data
数据库Data
招聘Recruitment
联系我们Contact
友情链接Links
游戏葡萄订阅号扫一扫,访问微社区
后使用快捷导航没有帐号?
签到成功!您今天第{todayrank}个签到,签到排名竞争激烈,记得每天都来签到哦!已连续签到:{constant}天,累计签到:{days}天
当前位置: &
查看: 2522|回复: 5
Unity序列化(1):工作原理和实例
71989/5000排名<font color="#FF昨日变化1主题帖子积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
在线时间666 小时
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
才可以下载或查看,没有帐号?
本帖最后由 caedmom 于
09:04 编辑
Unity序列化(1):工作原理和实例
This post is part of a series about Unityserialization. Click
forpart 1: how it works and examples and click
forpart 2: defining a serializable type.接下来让我们哔哔一下【序列化】。链接如下:Unity序列化(1):工作原理和实例 Unity序列化(2):定义序列化类型
On this series of articles (2, maybe 3) wewill discuss a topic that is extremely&&important to development: serialization. This subject may be a bit cloudy for beginners, butunderstanding it not only helps to figure out how the Unity engine works,but it can also become really handy during a game development process andassist you to build better solutions. We will concentrate our study on thefollowing subjects:
我们会在这个系列的第二或者第三部分详细解说最重要的开发技术:序列化。当然,新手一开始遇到这个技术难点肯定会一脸懵逼。但相信您经过以下的文档培训,您不仅会了解序列化在Unity中的工作原理,并且会使用它帮助您寻找更好的解决方案。以下为本次文档大纲:
§&&What is it? (Part 1)序列化的概念
§&&How Unity does (Part 1) Unity的序列化工作原理
§&&Examples (Part 1)&&序列化案例
§&&Defining a Serializable Type () 自定义序列化类型
§&&Problems with Serialization () 自定义序列化的存在的
§&&Scriptable Objects ()& &序列化脚本对象
Fell free tonavigate through the sections if you are comfortable with the previousconcepts.如果您对上述某些章节有所理解,可以直接跳过学习后面其他内容。
What is it?&&序列化的概念
Among other , serialization is the process of converting the state anobject to a set of bytes in order to store (or transmit) the object intomemory, a database or a file. In another words: it’s how you can save an objectto restore its state for later use.
长篇大论起来,序列化就是一个将对象的状态信息转换为可以存储或传输到内存,数据库或者文件的过程。简而言之,就是如何存储对象以便后续调用的过程。
Let’s say you have a Vector3 and you need tostore it for future use. Which fields would you save into a file to restore itsstate? X, Y and Z, that’s easy! Apply this rule for any object and if youserialize all the (important) data, you can reload the object exactly how itwas before. We name the process of storing the state of the object as“serialization” and the reverse process of building an object out of a file“deserialization”.
假设我们需要定义和存储一个向量,那这个向量的哪些字段状态我们需要保存起来?很明显是向量的三个分量X.Y,Z啦。您可以考虑将重要的数据进行序列化操作,以便在后续进行反序列化的操作。在这里我们再次简明概括一下序列化以及反序列化。序列化: 将数据结构或对象转换成二进制串的过程反序列化:将在序列化过程中所生成的二进制串转换成数据结构或者对象的过程
As wealready read, this process is really useful to store and transmit data, sothink about this: you have an online store deployed on your server, probablyrunning a database manager application aside. Eventually, we need to store thedata from memory into the disk (primary storage is volatile) and we do itby serializing our objects into database tables (which basically are files).The same process happens with every application that needs to store data into adisk, and computer games (and engines) are not an exception.
正如我们所分析那样,序列化经常用于存储或者转化数据。假设我们在我们的服务器上部署了一个商城,并且正常运行了数据库管理应用。那么,将内存数据((内存数据断电即丢失))写入硬盘的操作过程就是将对象序列化成数据表的实例。其他平台的数据存储操作,也属于序列化的范畴。
How Unity Does&&Unity的序列化工作原理Unity, as a Game Engine, needs to load a lot ofstuff (scripts, prefabs, scenes) from the disk into the memorywithin application data. Maybe more important than that, Unity needs tomove data between the native C++ side of the engine and the managed C#side. Even though we may think this task is strict to loading and storingassets processes, the serialization is used in many more situations thanwe think (like inspector window, reloading of editor code and instantiationamong other scenarios). You can learn a bit more about Unity Serialization ontheir .I’d risk to say it’s a mandatory read for developers.
Unity作为一个,除了需要从外部(磁盘)加载一大堆资源,如脚本,预设以及场景等到内存,还需要将数据从原生C++端转移到C#端进行托管。序列化操作不仅限于底层数据的加载和存储,它在前端界面也有所应用,如属性窗口,编辑器重定义以及场景对象实例化等。鉴于个人能力有限,您可以在本帖子的延伸阅读(最下方)找寻其他作者关于Unity序列化的博文。我相信处女座的同学会立马谷歌一下。
The UnityEngine.Object class (which isserializable) provides us with the serialization resource in Unity: anyother class than inherits from it – that includes MonoBehaviour,ScriptableObject (more on this later on the series), Shader, Sprite andbasically everything in Unity – can also be serialized. Most of its uses areinvisible and don’t matter when developing a game, except for a major use:scripting. When you create scripts, you need to keep on mind which fields youwant to serialize, and, to do so, your field :
已被序列化的UnityEngine.Object类会提供相应的序列化资源 :如MonoBehaviour,ScriptableObject(稍后会提到),Shader,Sprite以及Unity的基础内置资源。一般上述资源在游戏开发过程中的调用不可见,除了在脚本编写的环节才有所体现。毕竟在脚本编码过程中,您需要关注哪些字段需要被序列化。如果要对字段进行序列化,您必须遵循以下规则:
§&&Be public, or have [SerializeField] attribute将该字段定义为public,或者为其添加【SerializeField】的属性
§&&Not be static&&该字段不能使用static关键字
§&&Not be const&&该字段不能使用const关键字
§&&Not be readonly该字段不能使用readonly关键字
§&&The fieldtype needs to be of a typethat we can serialize.& &字段的数据类型必须能序列化
Which fieldtypes can we serialize? According toUnity’s : 通过查询unity文档可知,以下类型可被序列化:
§&&Custom non abstract classes with[Serializable] attribute.&&带有[Serializable]属性的自定义非抽象类
§&&Custom structs with [Serializable]attribute. (New in Unity 4.5)&&带有[Serializable]属性的自定义结构体
§&&References to objects that derive fromUntiyEngine.Object&&继承自UntiyEngine.Object的对象引用
§&&Primitive data types(int,float,double,bool,string,etc)&&基本数据类型(int,float,double,bool,string等)
§&&Array of a fieldtype we can serialize&&能序列化的字段数组
§&&List&T& of a fieldtype we canserialize能序列化的线性表
A really common data structure isn’tserializable: Dictionaries, even if you declare them as public, and[SerializeField] atribute. So keep that in mind when developing a game.需要重点关注的是,自定义的字典类型数据是不能序列化的,就算定义其为公有或附带[SerializeField]属性。鉴于上述原因,在游戏开发过程中,应避免使用字典进行序列化。
Ok, this is a lot of information, so let’sbreak it to a straightforward code example:说了那么多,让我们来实战一下。
Examples 案例
Let’s take the followingcode (MyBehaviour.cs) as an example:可复制以下代码到C#文件进行调试:
[C#] 纯文本查看 复制代码using UnityEpublic class MyBehaviour : MonoBehaviour
[SerializeField] private int x = 3;
[SerializeField] private float y = 5.6f;
public float pi = 3.1415f;
private int mySecret = 42;
public static int myStatic = 10;
public const int myConst = 22;
public readonly int myReadOnly = 99;
public int MyProperty { get { return 100; } }
The only fields that are serialized are “x”,“y” and “pi” because they are not static, const, readonly, a property orprivate with no [SerializeField] attribute. One way to show this is by taking alook at the script’s inspector, which only shows us serialized fields(that can come handy):
根据序列化原则可知,当字段含有static, const, readonly关键字或该字段定义为非公有时,不能被序列化,综上所述仅”x,y和pi”能被序列化。这些能被序列化的字段都可在脚本的属性面板进行查看。
04:49 上传
But there is a better way to show that theother fields were not serialized: by cloning the object. Remember I told youthat the Instantiate method uses the Unity serialization process? So let’s testit by adding the following method to our script:
通过对象克隆的方式,可输出并调试非序列化的字段。以下案例将阐述序列化过程中调用Instantiate方法的过程。
[C#] 纯文本查看 复制代码private void Start()
Debug.Log(“Pi: “ + pi + “. MySecret: “ + x+ “. MyStatic: “ + myStatic);// 译者注:MySecret的值引用的x,不知道是否错误,但我改为mySecrte时,2次输出同为42
}private void Update()
if (Input.GetMouseButtonDown(0))
mySecret = –11;
myStatic = 13;
GameObject.Instantiate(gameObject);
This method should modify the current objectand create another object in the scene when the mouse’s left button is pressed.A naive thought would be that since the second object is a clone of the firstone, it should have the same value for “pi”, “mySecret” and any other field asthe first object, right? Well, it does for “pi”, because it’s a public field(hence it’s serialized), but it doesn’t for “mySecret”: its value remainsunchanged when the secondDebug.Log() is executed:
运行上述程序并点击鼠标左键时,会在场景中引用当前对象并创建第二个对象。由于第二个对象是第一个对象的拷贝,我们是否可以认为第二个对象的值与第一个对象相同?参照输出列表发现,MySecret的值保持不变(没被序列化),而Pi的值改变了(序列化了)。
13.png (4.69 KB, 下载次数: 0)
04:49 上传
The field “mySecret” can’t be serializedbecause it’s a private field with no [SerializeField] attribute (which is theonly circumstance a private fields will be serialized*).
鉴于mySecret字段为private且没附带【SerializeField】属性,所以它不能被序列化。(某些场合私有字段可被序列化)。
*: Private fields are serialized in somecircumstances in the Unity Editor and that can lead us to some problems we willdiscuss later on the next article on the “Problems” session. ()
某些场合私有字段可被序列化,这种特殊情况会在【Problems】章节中进行描述。
Curiously, the value of “myStatic” changes inboth objects, but does that mean static fields are serializable? Theanswer is no. Even though its behavior leads us to conclude that, remember thatstatic fields belong to the class, and not to an instance of it. That said, ifwe, per example, create a new object and add a MyBehaviour script to it inplay mode (Using “GameObject & Create Empty” in the menu), “myStatic” willhave the same value as the other objects, although it isn’t a copy of any otherobject. However, note that the “pi” variable has its original value.
细心的读者肯定会发现,字段myStatic的值也发生了改变,那是否意味着它也被序列化了。答案是否定的。虽然控制台所输出的值会让我们认为该字段被序列化,但事实上仅仅因为它是静态字段,而静态字段仅属于类,而不属于类实例。如果我们新建一个空的物体【GameObject & Create Empty】并赋予它该脚本时,运行上述程序时,myStatic的值一样为13(没被序列化)。需要注意的是,Pi的值变为原来的值。
译者注:事实上我测试时值还是-4;
14.png (4.93 KB, 下载次数: 3)
04:49 上传
This proves what the Unity documentationtells us about how can we make a field of a serializable type be serialized.This works with most Unity objects, including MonoBehaviours, but what if Idon’t want to define a MonoBehaviour and I still want to create a Serializabletype? In other words, how can I define a Serializable type?上述案例用于简明介绍在unity中如何对一个可序列化的字段进行序列化操作。该原理适用于大多数Unity对象,如继承自MonoBehaviour。但如果我们不想使用MonoBehaviour所定义的对象但又想对它进行序列化操作呢?即如何定义一个序列化类型数据?
On the next article we will find out how to declare our own serializabletypes and how to treat problems that can come along with it.在下一个章节中我们将探讨如何声明序列化类型以及处理自定义序列化所带来的问题。
Fell free to write me any suggestions,errors, complements or just to say hi on the comments section.欢迎大家对我的帖子进行点评,如果觉得还行,请点个赞吧。
Source:延伸阅读 by Lucas Meijer (mandatory read)Unity的序列化------ Lucas Meijer(极力推荐)
by Tim CooperUnity序列化实战案例------ Tim Cooper
(C# and Visual Basic) 序列化操作(C#和VB版本)
扫描下方二维码关注官方微信~每日都有精选干货与你分享呦~
本文由蛮牛译馆倾情奉献,翻译:汉家郎,如有请及时联系,除 合作社区 及 合作媒体 外,禁止转载。
不可序列化unity中实例化;unity序列化;unity 反序列化;unity实例化;vb unity3d
每日推荐:
71989/5000排名<font color="#FF昨日变化1主题帖子积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
在线时间666 小时
序列化的意思是说再次读取Unity时序列化的变量是有值的,不需要你再次去赋值,因为它已经被保存下来。
每日推荐:
4469/500排名<font color="#FF昨日变化4主题帖子积分
四处流浪, 积分 469, 距离下一级还需 31 积分
四处流浪, 积分 469, 距离下一级还需 31 积分
蛮牛币1874
在线时间166 小时
先回帖在看
[]: loly5271 乐于助人,奖励 3
每日推荐:
71989/5000排名<font color="#FF昨日变化1主题帖子积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
在线时间666 小时
先回帖在看
多谢顶贴,如果有何错误,烦请指正~
每日推荐:
61300/1500排名<font color="#FF昨日变化4主题帖子积分
蛮牛粉丝, 积分 1300, 距离下一级还需 200 积分
蛮牛粉丝, 积分 1300, 距离下一级还需 200 积分
在线时间317 小时
磁盘存储也有文本文件,所以文本文件也是序列化
每日推荐:
71989/5000排名<font color="#FF昨日变化1主题帖子积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
日久生情, 积分 1989, 距离下一级还需 3011 积分
在线时间666 小时
磁盘存储也有文本文件,所以文本文件也是序列化
恩恩,正解
每日推荐:
经过游戏蛮牛认证的蛮牛小翻译关于Unity Attribute的一些总结 - 简书
关于Unity Attribute的一些总结
举两个例子,在变量上使用[SerializeFiled]属性,可以强制让变量进行序列化,可以在Unity的Editor上进行赋值。在Class上使用[RequireComponent]属性,就会在Class的GameObject上自动追加所需的Component。以下是Unity官网文档中找到的所有Attribute,下面将按照顺序,逐个对这些Attribute进行说明和小的测试。部分例子使用了Unity官方的示例。UnityEngine
AddComponentMenu
可以在UnityEditor的Component的Menu中增加自定义的项目。菜单可以设置多级,使用斜线/分隔即可。在Hierarchy中选中GameObject的时候,点击该菜单项,就可以在GameObject上追加该Component。例如如下代码可以完成下图的效果。[AddComponentMenu("TestMenu/TestComponet")]public class TestMenu : MonoBehaviour {}
Paste_Image.png
AssemblyIsEditorAssembly
汇编级属性,使用该属性的Class会被认为是EditorClass。具体用法不明。ContextMenu可以在Inspector的ContextMenu中增加选项。例如,如下代码的效果
public class TestMenu : MonoBehaviour {
[ContextMenu ("Do Something")]
void DoSomething () {
Debug.Log ("Perform operation"); }
Paste_Image.png
ContextMenuItemAttribute
这个属性是Unity4.5之后提供的新功能,可以在Inspector上面对变量追加一个右键菜单,并执行指定的函数。例子:
public class Sample : MonoBehaviour {
[ContextMenuItem("Reset", "ResetName")]
public string name = "Default";
void ResetName() {
name = "Default";
Paste_Image.png
DisallowMultipleComponent
对一个MonoBehaviour的子类使用这个属性,那么在同一个GameObject上面,最多只能添加一个该Class的实例。尝试添加多个的时候,会出现下面的提示。
Paste_Image.png
ExecuteInEditMode
默认状态下,MonoBehavior中的Start,Update,OnGUI等方法,需要在Play的状态下才会被执行。这个属性让Class在Editor模式(非Play模式)下也能执行。但是与Play模式也有一些区别。例如:Update方法只在Scene编辑器中有物体产生变化时,才会被调用。OnGUI方法只在GameView接收到事件时,才会被调用。
HeaderAttribute
这个属性可以在Inspector中变量的上面增加Header。例子:
public class ExampleClass : MonoBehaviour {
[Header("生命值")]
public int CurrentHP = 0;
public int MaxHP = 100;
[Header("魔法值")]
public int CurrentMP = 0;
public int MaxMP = 0;
Paste_Image.png
HideInInspector
在变量上使用这个属性,可以让public的变量在Inspector上隐藏,也就是无法在Editor中进行编辑。
ImageEffectOpaque
在OnRenderImage上使用,可以让渲染顺序在非透明物体之后,透明物体之前。例子
[ImageEffectOpaque]
void OnRenderImage (RenderTexture source, RenderTexture destination){}
ImageEffectTransformsToLDR
渲染从从HDR变为LDR 具体使用方法不明。
MultilineAttribute
在string类型上使用,可以在Editor上输入多行文字。
public class TestString : MonoBehaviour {
[MultilineAttribute]
public string mT
Paste_Image.png
NotConvertedAttribute
在变量上使用,可以指定该变量在build的时候,不要转换为目标平台的类型。
NotFlashValidatedAttribute
在变量上使用,在Flash平台build的时候,对该变量不进行类型检查。Unity5.0中已经移除了这个属性。
NotRenamedAttribute
禁止对变量和方法进行重命名。Unity5.0中已经移除了这个属性。
PropertyAttribute
RangeAttribute
在int或者float类型上使用,限制输入值的范围
public class TestRange : MonoBehaviour
[Range(0, 100)] public int HP;
RequireComponent
在Class上使用,添加对另一个Component的依赖。当该Class被添加到一个GameObject上的时候,如果这个GameObject不含有依赖的Component,会自动添加该Component。且该Componet不可被移除。例子
[RequireComponent(typeof(Rigidbody))]
public class TestRequireComponet : MonoBehaviour {}
Paste_Image.png
如果尝试移除被依赖的Component,会有如下提示
Paste_Image.png
在方法上添加该属性,可以网络通信中对该方法进行RPC调用。
void RemoteMethod(){}
RuntimeInitializeOnLoadMethodAttribute
此属性仅在Unity5上可用。在游戏启动时,会自动调用添加了该属性的方法。
class MyClass
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad ()
Debug.Log("Game loaded and is running");
SelectionBaseAttribute
当一个GameObject含有使用了该属性的Component的时候,在SceneView中选择该GameObject,Hierarchy上面会自动选中该GameObject的Parent。
SerializeField
在变量上使用该属性,可以强制该变量进行序列化。即可以在Editor上对变量的值进行编辑,即使变量是private的也可以。在UI开发中经常可见到对private的组件进行强制序列化的用法。例子
public class TestSerializeField : MonoBehaviour
[SerializeField]
[SerializeField]
private Button _}
Paste_Image.png
SharedBetweenAnimatorsAttribute
用于StateMachineBehaviour上,不同的Animator将共享这一个StateMachineBehaviour的实例,可以减少内存占用。
SpaceAttribute
使用该属性可以在Inspector上增加一些空位。 例子:
public class TestSpaceAttributeByLvmingbei : MonoBehaviour {
public int nospace1 = 0;
public int nospace2 = 0;
[Space(10)]
public int space = 0;
public int nospace3 = 0;
Paste_Image.png
TextAreaAttribute
该属性可以把string在Inspector上的编辑区变成一个TextArea。例子:
public class TestTextAreaAttributeByLvmingbei : MonoBehaviour {
[TextArea]
public string mT
Paste_Image.png
TooltipAttribute
这个属性可以为变量上生成一条tip,当鼠标指针移动到Inspector上时候显示。
public class TestTooltipAttributeByLvmingbei : MonoBehaviour {
[Tooltip("This year is 2015!")]
public int year = 0;
Paste_Image.png
UnityAPICompatibilityVersionAttribute
用来声明API的版本兼容性
UnityEngine.Serialization
FormerlySerializedAsAttribute
该属性可以令变量以另外的名称进行序列化,并且在变量自身修改名称的时候,不会丢失之前的序列化的值。例子:
using UnityE
using UnityEngine.S
public class MyClass : MonoBehaviour {
[FormerlySerializedAs("myValue")]
private string m_MyV
public string myValue
get { return m_MyV }
set { m_MyValue = }
UnityEngine.Editor
该package为Editor开发专用
CallbackOrderAttribute
定义Callback的顺序
CanEditMultipleObjects
Editor同时编辑多个Component的功能
CustomEditor
声明一个Class为自定义Editor的Class
CustomPreviewAttribute
将一个class标记为指定类型的自定义预览Unity4.5以后提供的新功能例子:
[CustomPreview(typeof(GameObject))]
public class MyPreview : ObjectPreview
public override bool HasPreviewGUI()
public override void OnPreviewGUI(Rect r, GUIStyle background)
GUI.Label(r, target.name + " is being previewed");
CustomPropertyDrawer
标记自定义PropertyDrawer时候使用。当自己创建一个PropertyDrawer或者DecoratorDrawer的时候,使用该属性来标记。 TODO: 如何创建属于自己的Attribute
可以在Scene视图中显示自定义的Gizmo下面的例子,是在Scene视图中,当挂有MyScript的GameObject被选中,且距离相机距离超过10的时候,便显示自定义的Gizmo。Gizmo的图片需要放入Assets/Gizmo目录中。例子:
using UnityE
using UnityE
public class MyScript : MonoBehaviour {
public class MyScriptGizmoDrawer {
[DrawGizmo (GizmoType.Selected | GizmoType.Active)]
static void DrawGizmoForMyScript (MyScript scr, GizmoType gizmoType) {
Vector3 position = scr.transform.
if(Vector3.Distance(position, Camera.current.transform.position) & 10f)
Gizmos.DrawIcon (position, "300px-Gizmo.png");
Paste_Image.png
InitializeOnLoadAttribute
在Class上使用,可以在Unity启动的时候,运行Editor脚本。需要该Class拥有静态的构造函数。做一个创建一个空的gameobject的例子。例子:
using UnityE
using UnityE
[InitializeOnLoad]
class MyClass
static MyClass ()
EditorApplication.update += U
Debug.Log("Up and running");
static void Update ()
Debug.Log("Updating");
InitializeOnLoadMethodAttribute
在Method上使用,是InitializeOnLoad的Method版本。Method必须是static的。
在方法上使用,可以在Editor中创建一个菜单项,点击后执行该方法,可以利用该属性做很多扩展功能。 需要方法为static。例子:
using UnityE
using UnityE
using System.C
public class TestMenuItem : MonoBehaviour {
[MenuItem ("MyMenu/Create GameObject")]
public static void CreateGameObject()
new GameObject("lvmingbei's GameObject");
Paste_Image.png
PreferenceItem
使用该属性可以定制Unity的Preference界面。在这里就使用官方的例子:
using UnityE
using UnityE
using System.C
public class OurPreferences {
// Have we loaded the prefs yet
private static bool prefsLoaded =
// The Preferences
public static bool boolPreference =
// Add preferences section named "My Preferences" to the Preferences Window
[PreferenceItem ("My Preferences")]
public static void PreferencesGUI ()
// Load the preferences
if (!prefsLoaded)
boolPreference = EditorPrefs.GetBool ("BoolPreferenceKey", false);
prefsLoaded =
// Preferences GUI
boolPreference = EditorGUILayout.Toggle ("Bool Preference", boolPreference);
// Save the preferences
if (GUI.changed)
EditorPrefs.SetBool ("BoolPreferenceKey", boolPreference);
Paste_Image.png
UnityEditor.Callbacks
这个package中是三个Callback的属性,都需要方法为static的。
OnOpenAssetAttribute
在打开一个Asset后被调用。例子:
using UnityE
using UnityE
using UnityEditor.C
public class MyAssetHandler {
[OnOpenAssetAttribute(1)]
public static bool step1(int instanceID, int line) {
string name = EditorUtility.InstanceIDToObject(instanceID).
Debug.Log("Open Asset step: 1 ("+name+")");
// we did not handle the open
// step2 has an attribute with index 2, so will be called after step1
[OnOpenAssetAttribute(2)]
public static bool step2(int instanceID, int line) {
Debug.Log("Open Asset step: 2 ("+instanceID+")");
// we did not handle the open
PostProcessBuildAttribute
该属性是在build完成后,被调用的callback。同时具有多个的时候,可以指定先后顺序。例子:
using UnityE
using UnityE
using UnityEditor.C
public class MyBuildPostprocessor {
[PostProcessBuildAttribute(1)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
Debug.Log( pathToBuiltProject );
PostProcessSceneAttribute
使用该属性的函数,在scene被build之前,会被调用。具体使用方法和PostProcessBuildAttribute类似。}

我要回帖

更多关于 kryo 反序列化问题 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信