ScriptableObject是一个Unity中的object,不是GameObject的实例。你可以使用它来创建一个具有自己的变量和方法的类,其开销会比MonoBehaviour更小。 Unity的GameObject会默认包含一个Transform组件,体现为:1、在Inspector中可以看到Transform组件;2、继承了MonoBehaviour的类中可以直接调用transform参数。 SO不包含Transform并且存在...
Scriptable Object没有继承自MonoBehavior,而是继承自Scriptable Object,所以Scriptable Object不能当脚本挂载到GameObject上,也不能进行GetComponent等对GameObject的操作,同时Scriptable Object以Asset文件存储,但不论是MonoBehavior还是Scriptable Object最终都继承自Unity Object。 但要注意的是,虽然Scriptable Object没有继承自Mo...
publicclassTestObject:ScriptableObject { publicstringMyString; } 此时我们可以批量创建多个类型相同,但是内容不同的 scriptable object, 用于记录数据(用来记录grid大小以及特点),也可以用来制作编辑器工具(如 URP 资源文件)。 可用来接解决资源,比如每种敌人都有武器,如果每个武器都有数据,如果有大量敌人,那么数据就会...
我们创建一个C#脚本然后做点修改: [CreateAssetMenu(fileName = "##创建Scriptable Obj时候默认的名字",menuName = "##右键菜单里的路径,比如Make a Bullet/Bullet")]//方便从菜单快速创建子弹副本publicclassBullets:ScriptableObject{publicfloatbulletSpeedpublicfloatdamagepublicintlifeSpanpublicBulletTypebulletType} ...
FindObjectsByType Retrieves a list of all loaded objects of Type type. Instantiate Clones the object original and returns the clone. InstantiateAsync Captures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation. Operators OperatorDescr...
Unity实现出生点(Spawn Points)的Scriptable封装 传统设置游戏出生点是在场景中创建一堆GameObject并使用其Transform作为出生点位置。这是有点大材小用了。如果能封装出来到一个列表里面(Scriptable Object),需要使用的时候调用这个列表就不仅让层级列表少了一堆多余的GameObject,还可以实现序列化存储。当然不只是用于出生点...
{ SO_ItemList so_itemList; so_itemList = AssetDatabase.LoadAssetAtPath("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.item...
SerializedObject newserobj=newSerializedObject(serializedObject.FindProperty("scriptable").objectReference...
your project’s memory usage by avoiding copies of values. This is useful if your project has aprefabAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene.More ...
1 不允许从ScriptableObject.ctor构造函数(或实例字段初始化程序)调用ScriptableObject,而是在OnEnable中调用它。从ScriptableObject 'Find_Object_by_component‘调用。有关详细信息,请参阅“统一手册”中的“脚本序列化”页面。从ScriptableObject 'Find_Object_by_com ...