Scriptable Object没有继承自MonoBehavior,而是继承自Scriptable Object,所以Scriptable Object不能当脚本挂载到GameObject上,也不能进行GetComponent等对GameObject的操作,同时Scriptable Object以Asset文件存储,但不论是MonoBehavior还是Scriptable Object最终都继承自Unity Object。 但要注意的是,虽然Scriptable Object没有继承自Mo...
此时我们可以批量创建多个类型相同,但是内容不同的 scriptable object, 用于记录数据(用来记录grid大小以及特点),也可以用来制作编辑器工具(如 URP 资源文件)。 可用来接解决资源,比如每种敌人都有武器,如果每个武器都有数据,如果有大量敌人,那么数据就会被大量复制。如果武器数据是 scriptable object 那么这就是一种引...
默认情况下,该选项是禁用的。如果禁用,纹理只在GPU内存中扩展。如果启用,它不仅会被复制到GPU内存,还会被复制到主内存,从而使消耗增加一倍。因此,如果您不使用诸如 Texture.GetPixel 或Texture.SetPixel 的api,且仅使用Shader访问纹理,确保禁用它们。 同样,对于在运行时生成的纹理,将makeNoLongerReadable设置为true ...
Assetsbundle:即将资源打成 asset bundle 放在服务器或本地磁盘,然后使用WWW模块get 下来,然后从这个bundle中load某个object,unity官方推荐也是绝大多数商业化项目使用的一种方式。 Resource.Load:可以直接load并返回某个类型的Object,前提是要把这个资源放在Resource命名的文件夹下,Unity不管有没有场景引用,都会将其全部...
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 ...
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...
("Assets/Scriptable Object Assets/Items/so_Itemlist.asset", typeof(SO_ItemList)) as SO_ItemList; List<ItemDetails> itemDetailLists = so_itemList.itemDetails; ItemDetails itemDetail = itemDetailLists.Find(x => x.itemCode == itemCode); if(itemDetail!= null) { return itemDetail.item...
然后,我们使用简单的MonoBehaviour脚本来使用它。 publicclassPlayer:MonoBehaviour{publicCommandPrimaryCommand;publicCommandSecondaryCommand;voidUpdate(){if(Input.GetKeyDown(KeyCode.Z)){PrimaryCommand.Execute();}if(Input.GetKeyDown(KeyCode.X)){SecondaryCommand.Execute();}}} 我们在 PrimaryCommand和SecondaryComm...
当创建⼀个脚本化对象实例后使⽤AssetDatabase.CreateAsset()保存成资源),因为是作为本地资源保存的,所以在退出之后也不会丢失。 但只有在编辑器模式下才可以修改⾥⾯的数据,这是因为ScriptableObject对象虽然声明在UnityEngine中,但是它的Scriptable是通过UnityEditor命名空 ...
我们创建一个C#脚本然后做点修改: [CreateAssetMenu(fileName = "##创建Scriptable Obj时候默认的名字",menuName = "##右键菜单里的路径,比如Make a Bullet/Bullet")]//方便从菜单快速创建子弹副本publicclassBullets:ScriptableObject{publicfloatbulletSpeedpublicfloatdamagepublicintlifeSpanpublicBulletTypebulletType} ...