예제 #1
0
    public T LoadAssetBundle_Cache <T>(string resName, string resPath, string resType, string exResPath = "", bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object
    {
        if (string.IsNullOrEmpty(resName))
        {
            return(null);
        }

        if (string.IsNullOrEmpty(resPath) && !string.IsNullOrEmpty(exResPath))
        {
            int index = exResPath.IndexOf('/');

            resPath = exResPath.Substring(0, (index == -1 ? exResPath.Length : index));
        }

        UnityEngine.Object tempObject = C_MonoSingleton <C_PoolMgr> .GetInstance().Spawn(resName, resType);

        if (tempObject != null)
        {
            return(tempObject as T);
        }

        string assetBundleName = GetAssetBundleName(resName, resPath, resType, exResPath);

        return(C_ResMgr.LoadAssetBundleCache <T>(resName, GetAssetBundleFilePath(assetBundleName), isInstantiate, isForever));
    }
예제 #2
0
    public AudioClip LoadResource_Audio_XBL(string resName, string resPath = "")
    {
        if (string.IsNullOrEmpty(resName))
        {
            return(null);
        }

        if (string.IsNullOrEmpty(resPath))
        {
            resPath = "PackagingResources/c_framework/audio/xbl/";
        }

        return(C_ResMgr.LoadResource(resName, resPath) as AudioClip);
    }
예제 #3
0
    //加载UI资源,内置
    public GameObject LoadResource_GameObject(string resName, string resPath)
    {
        if (string.IsNullOrEmpty(resName) || string.IsNullOrEmpty(resPath))
        {
            return(null);
        }

        GameObject tempObject = C_ResMgr.LoadResource(resName, resPath) as GameObject;

        if (tempObject != null)
        {
            tempObject = GameObject.Instantiate(tempObject);
        }

        return(tempObject);
    }
예제 #4
0
    public void AsyncLoadResource <T>(string resName, string resPath, string resType, Action <T> callback, string exResPath = "", bool isForever = false) where T : UnityEngine.Object
    {
        if (string.IsNullOrEmpty(resName) || string.IsNullOrEmpty(resPath))
        {
            callback(null);
            return;
        }

        UnityEngine.Object tempObject = C_MonoSingleton <C_PoolMgr> .GetInstance().Spawn(resName, resType);

        if (tempObject != null)
        {
            callback(tempObject as T);
            return;
        }

        if (GameConfig.LocalResources == 0)
        {
            string assetBundleName = GetAssetBundleName(resName, resPath, resType, exResPath);

            if (m_AssetBundleManifest != null && Hash128.Parse("0") != m_AssetBundleManifest.GetAssetBundleHash(assetBundleName))
            {
                List <string> dpsList = GetAllDependencies(assetBundleName);

                C_ResMgr.AsyncLoadAssetBundle(resName, assetBundleName, dpsList, callback, isForever);
                return;
            }
        }

        string resourcePath = "";

        if (string.IsNullOrEmpty(exResPath))
        {
            resourcePath = "PackagingResources/" + resPath + "/" + resType + "/";
        }
        else
        {
            resourcePath = "PackagingResources/" + exResPath;
        }

        C_ResMgr.AsyncLoadResource(resName, resourcePath, callback);
    }
예제 #5
0
    public void AsyncLoadResource_Audio_BGM(string resName, Action <AudioClip> callback, string resPath = "")
    {
        if (callback == null)
        {
            return;
        }

        if (string.IsNullOrEmpty(resName))
        {
            callback(null);
            return;
        }

        if (string.IsNullOrEmpty(resPath))
        {
            resPath = "PackagingResources/c_framework/audio/bgm/";
        }

        C_ResMgr.AsyncLoadResource(resName, resPath, callback);
    }
예제 #6
0
    public void LoadAssetBundle_CacheList(string type, List <string> assetBundleNameList)
    {
        if (string.IsNullOrEmpty(type) || assetBundleNameList.Count == 0)
        {
            return;
        }

        try
        {
            List <string> assetBundlePathList = new List <string>();

            for (int i = 0; i < assetBundleNameList.Count; i++)
            {
                assetBundlePathList.Add(GetAssetBundleFilePath(assetBundleNameList[i]));
            }

            C_ResMgr.LoadAssetBundleCacheList(type, assetBundlePathList);
        }
        catch (Exception e)
        {
            C_DebugHelper.LogError("LoadAssetBundleCacheList : " + e);
        }
    }
예제 #7
0
    public T LoadResource <T>(string resName, string resPath, string resType, string exResPath = "", bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object
    {
        if (string.IsNullOrEmpty(resName))
        {
            return(null);
        }

        if (string.IsNullOrEmpty(resPath) && !string.IsNullOrEmpty(exResPath))
        {
            int index = exResPath.IndexOf('/');
            resPath = exResPath.Substring(0, (index == -1 ? exResPath.Length : index));
        }

        UnityEngine.Object tempObject = C_MonoSingleton <C_PoolMgr> .GetInstance().Spawn(resName, resType);

        if (tempObject != null)
        {
            return(tempObject as T);
        }

        //关卡a是内置资源包,需要使用内置资源
        if (GameConfig.LocalResources == 0)
        {
            string assetBundleName     = GetAssetBundleName(resName, resPath, resType, exResPath);
            string assetBundleFilePath = GetAssetBundleFilePath(assetBundleName);

            T temp1 = C_ResMgr.GetAssetBundleFormCache <T>(resName, assetBundleFilePath, isInstantiate, isForever);
            if (temp1 != null)
            {
                return(temp1);
            }

            if (m_AssetBundleManifest != null && Hash128.Parse("0") != m_AssetBundleManifest.GetAssetBundleHash(assetBundleName))
            {
                List <string> dpsList = new List <string>();

                if (!resName.Contains(".ogg"))
                {
                    dpsList = GetAllDependencies(assetBundleName);
                }
                //Debug.LogError("load bundle"+resName);
                T temp2 = C_ResMgr.LoadAssetBundle <T>(resName, assetBundleFilePath, dpsList, isInstantiate, isForever);
                if (temp2 != null)
                {
                    return(temp2);
                }
            }
        }

        string resourcePath = "";

        if (string.IsNullOrEmpty(exResPath))
        {
            resourcePath = "PackagingResources/" + resPath + "/" + resType + "/";
        }
        else
        {
            resourcePath = "PackagingResources/" + exResPath;
        }

        T resObject = C_ResMgr.LoadResource <T>(resName, resourcePath);

        if (isInstantiate && resObject != null)
        {
            resObject = GameObject.Instantiate(resObject);
        }

        if (resObject == null)
        {
            C_DebugHelper.LogError("-----------------------------------resName = " + resName + ", exResPath = " + exResPath + ", is null");
        }

        return(resObject);
    }
예제 #8
0
 public float GetProgressUnLoadAssetBundle_CacheList(string type)
 {
     return(C_ResMgr.GetAssetUnBundleCacheListProgress(type));
 }
예제 #9
0
 public void ForceUnloadAssetBundle_CacheList(string type)
 {
     C_ResMgr.ForceUnloadAssetBundleCacheList(type);
 }