コード例 #1
0
    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
    /// <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);
        }
    }
コード例 #3
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);
        }
    }
コード例 #4
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));
    }
コード例 #5
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));
        }
    }