Esempio n. 1
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);
    }
Esempio n. 2
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);
    }
Esempio n. 3
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);
    }