Scriptable Object没有继承自MonoBehavior,而是继承自Scriptable Object,所以Scriptable Object不能当脚本挂载到GameObject上,也不能进行GetComponent等对GameObject的操作,同时Scriptable Object以Asset文件存储,但不论是MonoBehavior还是Scriptable Object最终都继承自Unity Object。 但要注意的是,虽然Scriptable Object没有继承自Mo...
但只有在编辑器模式下才可以修改里面的数据,这是因为ScriptableObject对象虽然声明在UnityEngine中,但是它的Scriptable是通过UnityEditor命名空间下的类(例如Editor类等)来实现的, 所以ScriptableObject生成的数据资源文件在Editor外具有只读属性,这是非常需要注意的一点。如果我们需要在游戏中修改数据并存储下来,就不推荐使用Scr...
我们创建一个C#脚本然后做点修改: [CreateAssetMenu(fileName = "##创建Scriptable Obj时候默认的名字",menuName = "##右键菜单里的路径,比如Make a Bullet/Bullet")]//方便从菜单快速创建子弹副本publicclassBullets:ScriptableObject{publicfloatbulletSpeedpublicfloatdamagepublicintlifeSpanpublicBulletTypebulletType} ...
public string SavedSettingsPath { get { return System.IO.Path.Combine(Application.persistentDataPath, "tanks-settings.json"); } } void Start () { if (System.IO.File.Exists(SavedSettingsPath)) GameSettings.LoadFromJSON(SavedSettingsPath); else GameSettings.InitializeFromDefault(GameSettingsTemplate);...
GetAllAssetPaths; //获取所有的资源文件(不包含meta文件) AssetDatabase.GetAssetPath(object) //获取object对象的相对路径 AssetDatabase.Refresh(); //刷新 AssetDatabase.GetDependencies(string); //获取依赖项文件 Directory.Delete(p, true); //删除P路径目录 Directory.Exists(p); //是否存在P路径目录 ...
Every time you instantiate that prefab, it will get its own copy of that data. Instead of using this method and storing duplicated data, you can use a ScriptableObject to store the data and then access it by reference from all the prefabs. This means that there is one copy of the data...
OnDestroyThis function is called when the scriptable object will be destroyed. OnDisableThis function is called when the scriptable object goes out of scope. OnEnableThis function is called when the object is loaded. Inherited members Variables ...
通常我们自定义的文件类型可以通过textasset 或scriptable object 来存储,区别在于前者是一个字节或文本流,后者要对应于程序中一个定义了的类型,textasset 还通常用于资源的加密。 2.动态load资源的几种途径: -通过Resources模块,调用它的load函数:可以直接load并返回某个类型的Object,前提是要把这个资源放在Resource命名...
public string InnerText { get; set; } //public XmlNode(string path, string name, ContentType cType) //{ // Path = path; // Name = name; // CType = cType; // AttributeDict = new Dictionary<string, string>(); // InnerTextList = new List<string>(); ...
JsonWriter 它的作用是负责将JsonMapper序列化好的Object文件写到硬盘上,它里面包含了文件具体写入时的一些规则 JsonReader 它的作用是负责将Json文件读取并解析成一串JsonToken,然后再提供给JsonMapper使用 三、改造工作 我们终于来到了激动人心的具体源码改造环节了,别急,让我们先搞清LitJson的工作原理。