Exemplo n.º 1
0
    protected T GetModel <T>(SerializableDictionaryBase <string, T> listModel, string assetBundlePath, string name, string remarkResourcesPath) where T : UnityEngine.Object
    {
        if (name == null)
        {
            return(null);
        }
        if (listModel.TryGetValue(name, out T value))
        {
            return(value);
        }

        T model = null;

#if UNITY_EDITOR
        //编辑器模式下直接加载资源
        if (!remarkResourcesPath.IsNull())
        {
            model = LoadAssetUtil.LoadAssetAtPathForEditor <T>(remarkResourcesPath);
        }
        else
        {
            model = LoadAssetUtil.SyncLoadAsset <T>(assetBundlePath, name);
        }
#else
        model = LoadAssetUtil.SyncLoadAsset <T>(assetBundlePath, name);
#endif

        if (model != null)
        {
            listModel.Add(name, model);
        }
        return(model);
    }
Exemplo n.º 2
0
    protected T GetModel <T>(SerializableDictionaryBase <string, T> listModel, string assetBundlePath, string name) where T : Object
    {
        if (name == null)
        {
            return(null);
        }
        if (listModel.TryGetValue(name, out T value))
        {
            return(value);
        }

        T anim = LoadAssetUtil.SyncLoadAsset <T>(assetBundlePath, name);

        if (anim != null)
        {
            listModel.Add(name, anim);
        }
        return(anim);
    }