加载Resource资源脚本

加载加载Resource资源脚本

    public GameObject Load(string path, string name)
    {
        GameObject prefab = Resources.Load<GameObject>(path) as GameObject;
        if (prefab == null)
        {
            Debug.LogWarning(path + " load fail");
            return null;
        }
        GameObject prefabClone = Instantiate(prefab);
        prefabClone.name = name;
        prefab = null;
        return prefabClone;
    }

发表评论

电子邮件地址不会被公开。 必填项已用*标注