void Start() { //****** GameObject go = new GameObject(); Test test = go.AddComponent <Test>(); MonoBehaviour[] mono = { test }; Destroy(go); //这部分代码是预制体本身需要添加脚本是才需要,这里是添加Test脚本 //****** //这段代码是测试加载预制体 MyCube和MySphere,这两个预制体都打包在名为cube的数据包内 loadResource = gameObject.AddComponent <LoadResource>(); loadResource.InitializePrefabs("cube", "MyCube", mono); loadResource.InitializePrefabs("cube", "MySphere", new Vector3(1f, 0f, 0f), mono); }