public void Init(string assetPackageFile, string assetPackagePackage, string assetWeigthFile, string assetWeightPackage, GameObject resourceLoader, Manifest manifest)
    {
        /*
         * public void Init (ResourceLoader resourceLoader, Manifest manifest)
         * {
         */
        Debug.Log("AssetPriManager Init");
        _initialzed      = InializedState.Initializing;
        isStartCoroutine = false;

        this._resourceLoaderObj = resourceLoader;
        this._manifest          = manifest;

        this._assetPackageFile    = ToAssetPriPath(assetPackageFile);
        this._assetPackagePackage = assetPackagePackage;
        this._assetWeightFile     = ToAssetPriPath(assetWeigthFile);
        this._assetWeightPackage  = assetWeightPackage;

        ResourceLoader resDl = _resourceLoaderObj.AddComponent <ResourceLoader> ();

        _assetPackageLoader = AssetLoaderManager.CreateLoader(_assetPackageFile, _assetPackagePackage);
        _assetWeightLoader  = AssetLoaderManager.CreateLoader(_assetWeightFile, _assetWeightPackage);

        resDl.AddAssetLoader(_assetPackageLoader);
        resDl.AddAssetLoader(_assetWeightLoader);
        resDl.SetProgressDelegate(InitCallBack, null, true);
    }
示例#2
0
        public Callback <AssetBundle[], int> LoadUI(string module)
        {
            string bytesAbPath   = AssetFileBook.GetUIPath(string.Format("{0}_fgui", module));
            string textureAbPath = AssetFileBook.GetUIPath(string.Format("{0}_altas", module));
            var    callback      = Callback <AssetBundle[], int> .GetOrNew();

            AssetLoaderManager.GetInstance().LoadAssetSync <AssetBundle>(bytesAbPath, (bytesAb) =>
            {
                AssetLoaderManager.GetInstance().LoadAssetSync <AssetBundle>(textureAbPath, (altasAb) =>
                {
                    callback?.onSuccess?.Invoke(new AssetBundle[] { bytesAb, altasAb });
                }, (altasBytes) =>
                {
                    if (bytesAb != null)
                    {
                        callback?.onSuccess?.Invoke(new AssetBundle[] { bytesAb, null });
                    }
                    else
                    {
                        callback?.onFailed?.Invoke(altasBytes);
                    }
                });
            }, (reasonBytes) =>
            {
                callback?.onFailed?.Invoke(reasonBytes);
            });
            return(callback);
        }
示例#3
0
 public static void Init()
 {
     AssetLoaderMgr = UnitySingleton <AssetLoaderManager> .Ins;
     NetMgr         = UnitySingleton <NetworkManager> .Ins;
     UIMgr          = UnitySingleton <UIManager> .Ins;
     AudioMgr       = UnitySingleton <AudioManager> .Ins;
     LuaMgr         = UnitySingleton <LuaManager> .Ins;
 }
示例#4
0
        /// <summary>
        /// 加载技能预制体
        /// </summary>
        /// <param name="prefabName"></param>
        /// <returns></returns>
        private GameObject LoadPrefab(string prefabName)
        {
            //加载到预制体
            var prefab = AssetLoaderManager.LoadAsset <GameObject>("uis/effect", prefabName);
            //通过对象池进行创建
            var skillGO = GameObjectPool.Instance.CreateObject(prefabName, prefab, Vector3.zero, Quaternion.identity);

            //回收物体
            GameObjectPool.Instance.CollectObject(skillGO);
            return(prefab);
        }
示例#5
0
    /// <summary>
    /// Releases all resource used by the <see cref="ResourceManager"/> object.
    /// </summary>
    /// <remarks>
    /// Call <see cref="Dispose"/> when you are finished using the <see cref="ResourceManager"/>. The <see cref="Dispose"/>
    /// method leaves the <see cref="ResourceManager"/> in an unusable state. After calling <see cref="Dispose"/>, you must
    /// release all references to the <see cref="ResourceManager"/> so the garbage collector can reclaim the memory that
    /// the <see cref="ResourceManager"/> was occupying.
    /// </remarks>
    public static void Dispose()
    {
        _initialzed = EInializedState.NotInitialized;
        GameObject.Destroy(_downloadObject);
        _manifest        = null;
        _manifestFile    = "";
        _manifestPackage = "";
        //_assetPriFile = "";
        //_assetPriPackage = "";
//		_assetPri = null;
        _pendingTask.Clear();
        AssetLoaderManager.DestroyAllLoaders();
    }
示例#6
0
        public Callback <GameObject, int> LoadSprite(string uid)
        {
            string assetPath = AssetFileBook.GetSpritePath(uid);
            var    callback  = Callback <GameObject, int> .GetOrNew();

            AssetLoaderManager.GetInstance().LoadAssetAsync <GameObject>(assetPath, (obj) =>
            {
                callback.onSuccess?.Invoke(obj);
            }, (reason) =>
            {
                callback.onFailed?.Invoke(reason);
            });
            return(callback);
        }
示例#7
0
        public string LoadConfig(string fileName)
        {
            string content   = null;
            string assetPath = AssetFileBook.GetConfigPath(fileName);
            var    callback  = Callback <string, int> .GetOrNew();

            AssetLoaderManager.GetInstance().LoadAssetSync <TextAsset>(assetPath, (textAsset) =>
            {
                content = textAsset.text;
            }, (reason) =>
            {
                callback.onFailed?.Invoke(reason);
            });
            return(content);
        }
示例#8
0
    IEnumerator InvokeDelegate(float progress)
    {
        _isCoroutineRun = true;
        yield return(new WaitForSeconds(0.1f));

        _progressDelegate(progress, _prgDlgtUserData);

        yield return(new WaitForSeconds(0.1f));

        foreach (AssetLoader assetLoader in _assetLoaders.Values)
        {
            AssetLoaderManager.DestroyLoader(assetLoader);
        }
        GameObject.Destroy(this);
    }
示例#9
0
    /// <summary>
    /// Load the specified asset object.
    /// The Load Method will be invoke in update thread
    /// </summary>
    /// <param name='assetFile'>
    /// Asset file.
    /// </param>
    public static void Load(string assetFile, out float progress, out Object loadObj, out bool isDone)
    {
        if (_initialzed != EInializedState.Initialized)
        {
            progress = 0F;
            loadObj  = null;
            isDone   = false;
            return;
        }

        /*
         * if (assetFile.StartsWith ("resources/")) {
         *      assetFile = PathUtil.RemoveLocalFlag (assetFile);
         *      progress =1.0F;
         *      loadObj = Resources.Load (assetFile);
         *      return;
         * }
         */

        progress = 0F;
        loadObj  = null;
        isDone   = false;
        if (_assetLoader != null)
        {
            /*
             * if (_assetLoader.Progress >= 1.0F) {
             *      loadObj = _assetLoader.Load ();
             *      _assetLoader = null;
             * }else{
             *      loadObj = null;
             * }
             * progress = _assetLoader.Progress;
             */
            progress = _assetLoader.Progress;
            isDone   = _assetLoader.IsDone;
            if (isDone)
            {
                loadObj      = _assetLoader.Load();
                _assetLoader = null;
            }
        }
        else
        {
            assetFile    = PathUtil.UnifyPath(assetFile);
            _assetLoader = AssetLoaderManager.CreateLoader(ToManifestPath(assetFile), _manifest);
        }
    }
示例#10
0
    public static Object LoadAfterDownLoad(string assetFile)
    {
        if (_initialzed != EInializedState.Initialized)
        {
            return(null);
        }

        assetFile = PathUtil.UnifyPath(assetFile);
        AssetLoader assetLoader = AssetLoaderManager.CreateLoader(ToManifestPath(assetFile), _manifest);

        if (assetLoader.Progress >= 1.0F)
        {
            return(assetLoader.Load());
        }
        else
        {
            return(null);
        }
    }
示例#11
0
    /// <summary>
    /// Initialize the manager with pecified basePath, manifestPackage and manifestFile.
    /// Before download asset, manager needs to be initialzed firstly.
    ///
    /// </summary>
    /// <param name='basePath'>
    /// Game resources base url path.
    /// </param>
    /// <param name='manifestPackage'>
    /// Manifest package file name.
    /// </param>
    /// <param name='manifestFile'>
    /// Manifest file name.
    /// </param>
    public static void Initialize(string basePath, string manifestFile, string manifestPackage, string assetPackageFile, string assetPackagePackage, string assetWeightFile, string assetWeightPackage)
    {
        Debug.Log("Resource Manager Init ");
        if (_initialzed != EInializedState.NotInitialized)
        {
            return;
        }

        //PlayerPrefs.DeleteAll();
        //PlayerPrefs.SetInt("PlayerLevel",1);

        _initialzed = EInializedState.Initializing;


        WwwLoaderManager.BasePath = basePath;
        _manifestFile             = ToManifestPath(manifestFile);
        _manifestPackage          = manifestPackage;

        _assetPackageFile    = assetPackageFile;
        _assetPackagePackage = assetPackagePackage;
        _assetWeightFile     = assetWeightFile;
        _assetWeightPackage  = assetWeightPackage;

        //_assetPriFile = ToManifestPath (assetPriFile);
        //_assetPriPackage = assetPriPackage;

        _downloadObject = new GameObject("ResourceLoader");
        _resourceLoader = _downloadObject.AddComponent <ResourceLoader> ();

        AssetLoader assetLoaderManifest = AssetLoaderManager.CreateLoader(_manifestFile, _manifestPackage);
        //AssetLoader assetLoaderAssetPri = AssetLoaderManager.CreateLoader (_assetPriFile, _assetPriPackage);

        List <AssetLoader> assetLoaderList = new List <AssetLoader>();

        assetLoaderList.Add(assetLoaderManifest);
        //assetLoaderList.Add(assetLoaderAssetPri);

        _resourceLoader.SetProgressDelegate(InitializeCallback, assetLoaderList, true);
        _resourceLoader.AddAssetLoader(AssetLoaderManager.CreateLoader(_manifestFile, _manifestPackage));
        //_resourceLoader.AddAssetLoader (AssetLoaderManager.CreateLoader (_assetPriFile, _assetPriPackage));
    }
示例#12
0
    /// <summary>
    /// Download the specified assets.
    /// </summary>
    /// <param name='dlObject'>
    /// The download object which affact the downloading task.
    /// The task can be canceled by destroying this download object.
    /// </param>
    /// <param name='prgDelegate'>
    /// Prgogress delegate to be callback after downloaded.
    /// </param>
    /// <param name='prgUserData'>
    /// Prgogress delegate user data.
    /// </param>
    /// <param name='assetFiles'>
    /// Asset files.
    /// </param>
    public static void Download(GameObject dlObject, DownloadDelegate prgDelegate, System.Object prgUserData, bool isReturnPerFrame, params string [] assetFiles)
    {
        if (assetFiles.Length == 0)
        {
            return;
        }

        if (_initialzed != EInializedState.Initialized)
        {
            DownloadTask dlTask = new DownloadTask();
            dlTask.DownloadObect    = dlObject;
            dlTask.ProgressFunction = prgDelegate;
            dlTask.ProgressUserData = prgUserData;

            foreach (string assetFile in assetFiles)
            {
                dlTask.AssetFiles.Add(assetFile);
            }

            _pendingTask.Add(dlTask);

            return;
        }

        if (dlObject == null)
        {
            dlObject = _downloadObject;
        }

        ResourceLoader resDl = dlObject.AddComponent <ResourceLoader> ();

        resDl.SetProgressDelegate(prgDelegate, prgUserData, isReturnPerFrame);

        foreach (string assetFile in assetFiles)
        {
            resDl.AddAssetLoader(AssetLoaderManager.CreateLoader(ToManifestPath(assetFile), _manifest));
        }
    }
示例#13
0
        static int _m_LoadAsset_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    string      _bundleName = LuaAPI.lua_tostring(L, 1);
                    string      _assetName  = LuaAPI.lua_tostring(L, 2);
                    System.Type _type       = (System.Type)translator.GetObject(L, 3, typeof(System.Type));

                    UnityEngine.Object gen_ret = AssetLoaderManager.LoadAsset(_bundleName, _assetName, _type);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
示例#14
0
        private void Start()
        {
            string assetPath = AssetFileBook.GetBundleMainfest();

            AssetLoaderManager.GetInstance().LoadBundleMainfest(assetPath);
        }