예제 #1
0
    // Use this for initialization
    void Start()
    {
        Debug.Log(Application.dataPath);
        Debug.Log(Application.streamingAssetsPath);
        Debug.Log(Application.persistentDataPath);

        APPEngineManager.GetInstance().OnAssetUpdateDoneAct += Test;
        gameObject.SetActive(false);
    }
예제 #2
0
    /// <summary>
    /// 加载Sprite 资源 由于所有的Sprite 按照文件夹打包的,需要单独处理
    /// </summary>
    /// <param name="assetPath"></param>
    /// <param name="callback"></param>
    public void LoadSprite(string assetPath, System.Action <UnityEngine.Object> callback)
    {
        UnityEngine.Object result = null;
        if (APPEngineManager.GetInstance().m_IsAssetUpdating || Manifest == null)
        {
            Debug.LogInfor("如果不存在AssetBundle 则尝试加载本地Resources中资源");
            GetLocalResourcesAsset(assetPath, ref result);  //如果不存在AssetBundle 则尝试加载本地Resources中资源
            if (callback != null)
            {
                callback(result);
            }
            return;
        }  //Manifest 加载失败
        string parentDirectoryName = System_IO_Path_Ex.GetPathParentDirectoryName(assetPath);//获取一个文件下打包的Sprite

        Debug.LogInfor("LoadSprite  parentDirectoryName=" + parentDirectoryName);


        //Debug.LogInfor("abundlePath=" + abundlePath);
        string assetDirectoryPath = System.IO.Path.GetDirectoryName(assetPath);
        string spriteAssetPath    = assetDirectoryPath + "/" + parentDirectoryName;

        string spriteAbundlepath = ConstDefine.ABundleTopPath + ConstDefine.ABundleTopFileNameOfPlatformat + "/" + spriteAssetPath + ConstDefine.ABundleObjExtensitonName;

        Debug.LogInfor("spriteAbundlepath=" + spriteAbundlepath);
        if (System.IO.File.Exists(spriteAbundlepath))
        {
            result = LoadSpriteAssetByPath(spriteAssetPath, System.IO.Path.GetFileName(assetPath));
        }//只有当外部存储内存中存在该资源时读取 否则使用Reources中的资源

        if (result != null)
        {
            if (callback != null)
            {
                callback(result);
            }
            return;
        }
        GetLocalResourcesAsset(assetPath, ref result);  //如果不存在AssetBundle 则尝试加载本地Resources中资源
        if (callback != null)
        {
            callback(result);
        }
    }
예제 #3
0
    /// <summary>
    /// 加载资源的统一入口 当外部AssetBundle 资源不存在时候 会尝试加载Resources中的资源 但是可能会出现异常情况
    /// </summary>
    /// <param name="assetPath">资源相对于Reources的路径</param>
    /// <param name="callback"></param>
    public void LoadAsset(string assetPath, Action <UnityEngine.Object> callback)
    {
        UnityEngine.Object result = null;
        Debug.Log("APPEngineManager.GetInstance().m_IsAssetUpdating=" + APPEngineManager.GetInstance().m_IsAssetUpdating);
        if (APPEngineManager.GetInstance().m_IsAssetUpdating || Manifest == null)
        {
            Debug.LogInfor("如果不存在AssetBundle 则尝试加载本地Resources中资源");
            GetLocalResourcesAsset(assetPath, ref result);  //如果不存在AssetBundle 则尝试加载本地Resources中资源
            if (callback != null)
            {
                callback(result);
            }
            return;
        }  //Manifest 加载失败
        string abundlePath = ConstDefine.ABundleTopPath + ConstDefine.ABundleTopFileNameOfPlatformat + "/" + assetPath + ConstDefine.ABundleObjExtensitonName;

        Debug.LogInfor("abundlePath=" + abundlePath);
        if (File.Exists(abundlePath))
        {
            result = LoadAssetByPath(assetPath);
        }//只有当外部存储内存中存在该资源时读取 否则使用Reources中的资源

        if (result != null)
        {
            if (callback != null)
            {
                callback(result);
            }
            return;
        }
        GetLocalResourcesAsset(assetPath, ref result);  //如果不存在AssetBundle 则尝试加载本地Resources中资源
        if (callback != null)
        {
            callback(result);
        }
    }