コード例 #1
0
        public ResourceRequireData(
			string path , bool autosave , long utime , bool autoClear ,
			RESOURCE_TYPE type, ENCRYPT_TYPE encrypt_type, DecryptBytesFunc decryptFunc
			)
        {
            this.m_strFilePath = path;
            this.m_cPathUri = new Uri(path);
            this.m_lUTime = utime;
            this.m_bAutoSave = autosave;
            this.m_bAutoClear = autoClear;
            this.m_eResType = type;
            this.m_eEncryType = encrypt_type;
            this.m_funDecryptFunc = decryptFunc;
            this.m_fLastUseTime = Time.fixedTime;
        }
コード例 #2
0
 public ResourceRequireData(
     string path, bool autosave, long utime, bool autoClear,
     RESOURCE_TYPE type, ENCRYPT_TYPE encrypt_type, DecryptBytesFunc decryptFunc
     )
 {
     this.m_strFilePath    = path;
     this.m_cPathUri       = new Uri(path);
     this.m_lUTime         = utime;
     this.m_bAutoSave      = autosave;
     this.m_bAutoClear     = autoClear;
     this.m_eResType       = type;
     this.m_eEncryType     = encrypt_type;
     this.m_funDecryptFunc = decryptFunc;
     this.m_fLastUseTime   = Time.fixedTime;
 }
コード例 #3
0
 /// <summary>
 /// 开始WW加载
 /// </summary>
 /// <param name="path"></param>
 /// <param name="crc"></param>
 /// <param name="version"></param>
 /// <param name="callback"></param>
 /// <param name="res_type"></param>
 /// <param name="encrypt_type"></param>
 /// <param name="decryptFunc"></param> 
 public static LoadPackage StartWWW(
     string path ,
     bool autosave = false , long utime = 0 , DOWN_FINISH_CALLBACK callback = null,
     DOWN_ERROR_CALLBACK error_call = null,
     RESOURCE_TYPE res_type = RESOURCE_TYPE.WEB_ASSETBUNLDE,
     ENCRYPT_TYPE encrypt_type = ENCRYPT_TYPE.NORMAL,
     DecryptBytesFunc decryptFunc = null
     )
 {
     GameObject obj = new GameObject("WWWLoad");
     LoadPackage loader = obj.AddComponent<LoadPackage>();
     loader.Init(
         path , autosave ,utime , callback,error_call,
         res_type, encrypt_type, decryptFunc);
     loader.StartCoroutine("Load");
     return loader;
 }
コード例 #4
0
        private bool m_bAutoSave;                     //auto save function.

        /// <summary>
        /// 开始WW加载
        /// </summary>
        /// <param name="path"></param>
        /// <param name="crc"></param>
        /// <param name="version"></param>
        /// <param name="callback"></param>
        /// <param name="res_type"></param>
        /// <param name="encrypt_type"></param>
        /// <param name="decryptFunc"></param>
        public static LoadPackage StartWWW(
            string path,
            bool autosave = false, long utime = 0, DOWN_FINISH_CALLBACK callback = null,
            DOWN_ERROR_CALLBACK error_call = null,
            RESOURCE_TYPE res_type         = RESOURCE_TYPE.WEB_ASSETBUNLDE,
            ENCRYPT_TYPE encrypt_type      = ENCRYPT_TYPE.NORMAL,
            DecryptBytesFunc decryptFunc   = null
            )
        {
            GameObject  obj    = new GameObject("WWWLoad");
            LoadPackage loader = obj.AddComponent <LoadPackage>();

            loader.Init(
                path, autosave, utime, callback, error_call,
                res_type, encrypt_type, decryptFunc);
            loader.StartCoroutine("Load");
            return(loader);
        }
コード例 #5
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="id"></param>
 private void Init(
     string path,
     bool autosave = false, long utime = 0,
     DOWN_FINISH_CALLBACK callback  = null,
     DOWN_ERROR_CALLBACK error_call = null,
     RESOURCE_TYPE res_type         = RESOURCE_TYPE.WEB_ASSETBUNLDE,
     ENCRYPT_TYPE encrypt_type      = ENCRYPT_TYPE.NORMAL,
     DecryptBytesFunc decryptFunc   = null
     )
 {
     this.m_strPath        = path;
     this.m_lUTime         = utime;
     this.m_bComplete      = false;
     this.m_cWww           = null;
     this.m_cCallBack      = callback;
     this.m_cErrorCallBack = error_call;
     this.m_delDecryptFunc = decryptFunc;
     this.m_eEncryptType   = encrypt_type;
     this.m_eResType       = res_type;
     this.m_fProgess       = 0;
     this.m_bAutoSave      = autosave;
 }
コード例 #6
0
        /// <summary>
        /// Requests the resouce.
        /// </summary>
        /// <returns>The resouce.</returns>
        /// <param name="path">Path.</param>
        /// <param name="crc">Crc.</param>
        /// <param name="version">Version.</param>
        /// <param name="autoSave">If set to <c>true</c> auto save.</param>
        /// <param name="utime">Utime.</param>
        /// <param name="autoClear">If set to <c>true</c> auto clear.</param>
        /// <param name="resType">Res type.</param>
        /// <param name="encrypt_type">Encrypt_type.</param>
        /// <param name="func">Func.</param>
        /// <param name="error_call">Error_call.</param>
        /// <param name="arg">Argument.</param>
        public static ResourceRequireOwner RequestResouce(
            string path, bool autoSave, long utime, bool autoClear, RESOURCE_TYPE resType,
            ENCRYPT_TYPE encrypt_type, REQUEST_FINISH_CALLBACK func,
            REQUEST_ERROR_CALLBACK error_call, object[] arg
            )
        {
            if (sInstance.m_delDecryptFunc == null && encrypt_type == ENCRYPT_TYPE.ENCRYPT)
            {
                // Error
                // 没有资源解密接口
                return(null);
            }

            string resName = (new Uri(path)).AbsolutePath;

            ResourceRequireOwner owner = new ResourceRequireOwner();

            owner.m_cResName = resName;
//            owner.m_strResValue = resValue;
            owner.m_delCallBack  = func;
            owner.m_delErrorCall = error_call;
            owner.m_eResType     = resType;
            owner.m_vecArg       = arg;
            if (sInstance.m_eLoadType != LOAD_TYPE.NORMAL)
            {
                UnityEngine.Object obj = LoadEditor(resName);
                if (!sInstance.m_mapRes.ContainsKey(resName))
                {
                    object resData = null;
                    switch (resType)
                    {
                    case RESOURCE_TYPE.WEB_ASSETBUNLDE:
                    case RESOURCE_TYPE.WEB_TEXTURE:
                        resData = obj;
                        break;

                    case RESOURCE_TYPE.WEB_TEXT_BYTES:
                        resData = (obj as TextAsset).bytes;
                        break;

                    case RESOURCE_TYPE.WEB_TEXT_STR:
                        resData = (obj as TextAsset).text;
                        break;
                    }
                    ResourceRequireData data = new ResourceRequireData(resData);
                    sInstance.m_mapRes.Add(resName, data);
                }
                sInstance.m_mapRes[resName].AddRequireOwner(owner);
                sInstance.m_mapRes[resName].Used();
                if (sInstance.m_mapRes[resName].Complete)
                {
                    sInstance.m_mapRes[resName].CompleteCallBack();
                }
                return(owner);
            }

            if (sInstance.m_mapRes.ContainsKey(resName))
            {
                //增加需求者
                sInstance.m_mapRes[resName].AddRequireOwner(owner);
                sInstance.m_mapRes[resName].Used();
                if (sInstance.m_mapRes[resName].Complete)
                {
                    sInstance.m_mapRes[resName].CompleteCallBack();
                }
            }
            else
            {
                ResourceRequireData rrd = new ResourceRequireData(
                    path, autoSave, utime, autoClear, resType,
                    encrypt_type, sInstance.m_delDecryptFunc);
                sInstance.m_lstRequires.Add(rrd);
                sInstance.m_mapRes.Add(resName, rrd);
                rrd.AddRequireOwner(owner);
            }

            return(owner);
        }
コード例 #7
0
        /// <summary>
        /// Requests the resouce.
        /// </summary>
        /// <returns>The resouce.</returns>
        /// <param name="path">Path.</param>
        /// <param name="autoSave">If set to <c>true</c> auto save.</param>
        /// <param name="utime">Utime.</param>
        /// <param name="autoClear">If set to <c>true</c> auto clear.</param>
        /// <param name="resType">Res type.</param>
        /// <param name="encrypt_type">Encrypt_type.</param>
        /// <param name="func">Func.</param>
        /// <param name="error_call">Error_call.</param>
        /// <param name="arg">Argument.</param>
        public static ResourceRequireOwner RequestResouce(
            string path , bool autoSave , long utime , bool autoClear , RESOURCE_TYPE resType,
            ENCRYPT_TYPE encrypt_type, REQUEST_FINISH_CALLBACK func ,
            REQUEST_ERROR_CALLBACK error_call,object[] arg
            )
        {
            if (sInstance.m_delDecryptFunc == null && encrypt_type == ENCRYPT_TYPE.ENCRYPT )
            {
                // Error
                // 没有资源解密接口
                return null;
            }

            string resName = (new Uri(path)).AbsolutePath;

            ResourceRequireOwner owner = new ResourceRequireOwner();
            owner.m_cResName = resName;
            //            owner.m_strResValue = resValue;
            owner.m_delCallBack = func;
            owner.m_delErrorCall = error_call;
            owner.m_eResType = resType;
            owner.m_vecArg = arg;
            if ( sInstance.m_eLoadType != LOAD_TYPE.NORMAL )
            {
                UnityEngine.Object obj = LoadEditor(resName);
                if (!sInstance.m_mapRes.ContainsKey(resName))
                {
                    object resData = null;
                    switch( resType )
                    {
                    case RESOURCE_TYPE.WEB_ASSETBUNLDE:
                    case RESOURCE_TYPE.WEB_TEXTURE:
                        resData = obj;
                        break;
                    case RESOURCE_TYPE.WEB_TEXT_BYTES:
                        resData = (obj as TextAsset).bytes;
                        break;
                    case RESOURCE_TYPE.WEB_TEXT_STR:
                        resData = (obj as TextAsset).text;
                        break;
                    }
                    ResourceRequireData data = new ResourceRequireData(resData);
                    sInstance.m_mapRes.Add(resName, data);
                }
                sInstance.m_mapRes[resName].AddRequireOwner(owner);
                sInstance.m_mapRes[resName].Used();
                if(sInstance.m_mapRes[resName].Complete)
                {
                    sInstance.m_mapRes[resName].CompleteCallBack();
                }
                return owner;
            }

            if (sInstance.m_mapRes.ContainsKey(resName))
            {
                //增加需求者
                sInstance.m_mapRes[resName].AddRequireOwner(owner);
                sInstance.m_mapRes[resName].Used();
                if (sInstance.m_mapRes[resName].Complete)
                {
                    sInstance.m_mapRes[resName].CompleteCallBack();
                }
            }
            else
            {
                ResourceRequireData rrd = new ResourceRequireData(
                    path , autoSave ,utime ,autoClear, resType,
                    encrypt_type, sInstance.m_delDecryptFunc);
                sInstance.m_lstRequires.Add(rrd);
                sInstance.m_mapRes.Add(resName, rrd);
                rrd.AddRequireOwner(owner);
            }

            return owner;
        }
コード例 #8
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="id"></param>
 private void Init(
     string path ,
     bool autosave = false, long utime = 0,
     DOWN_FINISH_CALLBACK callback = null,
     DOWN_ERROR_CALLBACK error_call = null,
     RESOURCE_TYPE res_type = RESOURCE_TYPE.WEB_ASSETBUNLDE,
     ENCRYPT_TYPE encrypt_type = ENCRYPT_TYPE.NORMAL,
     DecryptBytesFunc decryptFunc = null
     )
 {
     this.m_strPath = path;
     this.m_lUTime = utime;
     this.m_bComplete = false;
     this.m_cWww = null;
     this.m_cCallBack = callback;
     this.m_cErrorCallBack = error_call;
     this.m_delDecryptFunc = decryptFunc;
     this.m_eEncryptType = encrypt_type;
     this.m_eResType = res_type;
     this.m_fProgess = 0;
     this.m_bAutoSave = autosave;
 }