Unity3D: 动态加载Prefab

在Unity3D中,可能有这种需求:想实例化一个prefab,而该prefab又不在场景中。这时需要在Assets下建立Resources文件夹,然后把需要实例化的prefab拖入该文件夹中。最后在代码中这样实例化:

?
1
Instantiate(Resources.Load( "PrefabName" ), position, rotation)

猜你喜欢

转载自blog.csdn.net/qq_37405874/article/details/80135553