Exemplo n.º 1
0
    //同步加载
    public static Object Load(string path, Type type)
    {
        if (type == null)
        {
            type = typeof(GameObject);
        }

        Object prefab = null;

        if (!Instance.prefabMap.TryGetValue(path, out prefab))
        {
#if UNITY_EDITOR && !A_TEST
            prefab = UnityEditor.AssetDatabase.LoadAssetAtPath(GetPath(path), type);
#else
            prefab = BundleManager.GetAsset(path, type);
#endif
            if (prefab != null)
            {
                Instance.prefabMap[path] = prefab;
            }
        }

        if (prefab == null)
        {
            Debug.LogError(string.Format(ERROR_PATH, GetPath(path)));
        }

        return(prefab);
    }