示例#1
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);
    }
示例#2
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);
    }