美文网首页
2019-08-01【3D-Game-Kits】(未测试)从非R

2019-08-01【3D-Game-Kits】(未测试)从非R

作者: 持刀的要迟到了 | 来源:发表于2019-08-01 18:10 被阅读0次
image.png
    protected GameObject InstantiatePrefab (string folderPath, string prefabName)
    {
        GameObject instance = null;
        string[] prefabFolderPath = { folderPath };
        string[] guids = AssetDatabase.FindAssets (prefabName, prefabFolderPath);
    
        if(guids.Length == 0)
            Debug.LogError ("The " + prefabName + " prefab could not be found in " + folderPath + " and could therefore not be instantiated.  Please create one manually.");
        else if(guids.Length > 1)
            Debug.LogError ("Multiple " + prefabName + " prefabs were found in " + folderPath + " and one could therefore not be instantiated.  Please create one manually.");
        else
        {
            string path = AssetDatabase.GUIDToAssetPath (guids[0]);
            GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject> (path);
            instance = Instantiate (prefab);
        }

        return instance;
    }

相关文章

网友评论

      本文标题:2019-08-01【3D-Game-Kits】(未测试)从非R

      本文链接:https://www.haomeiwen.com/subject/vrbcdctx.html