unity 3d 怎么实现目录功能

2025-01-27 03:51:30
推荐回答(1个)
回答1:

// 通过Resources.LoadAtPath方法动态加载Prefab
private void LoadPrefabByResources()
{
Object prefab = Resources.LoadAssetAtPath("Assets/Prefabs/Cube.prefab", typeof(GameObject));
GameObject cube = (GameObject)Instantiate(prefab);
cube.transform.parent = transform;
}