Exemple #1
0
    // 读取StreamingAssets目录下的文件,只需要相对于StreamingAssets的路径即可(推荐使用这个函数)
    public static WWWFileLoadTask LoadFileAtStreamingAssetsPath(string fileName, bool usePlatform, ThreadPriority priority = ThreadPriority.Normal)
    {
        fileName = GetStreamingAssetsPath(usePlatform) + "/" + fileName;
        WWWFileLoadTask ret = LoadFileName(fileName, priority);

        return(ret);
    }
Exemple #2
0
    // 读取StreamingAssets目录下的文件,只需要相对于StreamingAssets的路径即可(推荐使用这个函数)
    public static WWWFileLoadTask LoadFileAtStreamingAssetsPath(string fileName, bool usePlatform)
    {
        fileName = GetStreamingAssetsPath(usePlatform) + "/" + fileName;
        WWWFileLoadTask ret = LoadFileName(fileName);

        return(ret);
    }
        private void OnFileListloaded(ITask task)
        {
            if (task.IsOk)
            {
                WWWFileLoadTask t      = task as WWWFileLoadTask;
                FileStream      stream = new FileStream(m_FileListName, FileMode.Create, FileAccess.Write);
                try
                {
                    stream.Write(t.ByteData, 0, t.ByteData.Length);
                } finally
                {
                    stream.Close();
                    stream.Dispose();
                    stream = null;
                }
            }


            if (!File.Exists(m_VersionName))
            {
                CopyVersion();
            }
            else
            {
                ToNextState();
            }
        }
Exemple #4
0
    public static BundleCreateAsyncTask LoadFileAtStreamingAssetsPath(string fileName, bool usePlatform, int priority = 0)
    {
        fileName = WWWFileLoadTask.GetStreamingAssetsPath(usePlatform, true) + "/" + fileName;
        BundleCreateAsyncTask ret = Create(fileName, priority);

        return(ret);
    }
Exemple #5
0
    // 传入为普通文件名(推荐使用这个函数)
    public static WWWFileLoadTask LoadFileName(string fileName)
    {
        string          wwwFileName = ConvertToWWWFileName(fileName);
        WWWFileLoadTask ret         = Create(wwwFileName);

        return(ret);
    }
Exemple #6
0
    // 传入为普通文件名(推荐使用这个函数)
    public static WWWFileLoadTask LoadFileName(string fileName, ThreadPriority priority = ThreadPriority.Normal)
    {
        string          wwwFileName = ConvertToWWWFileName(fileName);
        WWWFileLoadTask ret         = Create(wwwFileName, priority);

        return(ret);
    }
Exemple #7
0
 private static void PoolReset(WWWFileLoadTask task)
 {
     if (task == null)
     {
         return;
     }
     task.ItemPoolReset();
 }
Exemple #8
0
        internal WWWFileLoadTask CreateWWWStreamAssets(string fileName, bool usePlatform)
        {
            WWWFileLoadTask ret = WWWFileLoadTask.LoadFileAtStreamingAssetsPath(fileName, usePlatform);

            lock (m_Lock) {
                m_TaskList.AddTask(ret, true);
            }
            return(ret);
        }
Exemple #9
0
 private static void InPool(WWWFileLoadTask task)
 {
     if (!m_UsePool || task == null || task.m_IsInPool)
     {
         return;
     }
     InitPool();
     m_Pool.Store(task);
     task.m_IsInPool = true;
 }
Exemple #10
0
    public static WWWFileLoadTask Create(string wwwFileName)
    {
        if (string.IsNullOrEmpty(wwwFileName))
        {
            return(null);
        }
        WWWFileLoadTask ret = GetNewTask();

        ret.mWWWFileName = wwwFileName;
        return(ret);
    }
Exemple #11
0
    public static WWWFileLoadTask Create(string wwwFileName, ThreadPriority priority = ThreadPriority.Normal)
    {
        if (string.IsNullOrEmpty(wwwFileName))
        {
            return(null);
        }
        WWWFileLoadTask ret = GetNewTask();

        ret.mWWWFileName = wwwFileName;
        ret.mPriority    = priority;
        return(ret);
    }
Exemple #12
0
    private static WWWFileLoadTask GetNewTask()
    {
        if (m_UsePool)
        {
            InitPool();
            WWWFileLoadTask ret = m_Pool.GetObject();
            if (ret != null)
            {
                ret.m_IsInPool = false;
            }
            return(ret);
        }

        return(new WWWFileLoadTask());
    }
        private void OnVersionLoaded(ITask task)
        {
            if (task.IsOk)
            {
                WWWFileLoadTask t      = task as WWWFileLoadTask;
                FileStream      stream = new FileStream(m_VersionName, FileMode.Create, FileAccess.Write);
                try
                {
                    stream.Write(t.ByteData, 0, t.ByteData.Length);
                } finally
                {
                    stream.Close();
                    stream.Dispose();
                    stream = null;
                }
            }

            ToNextState();
        }
Exemple #14
0
        private void OnVersionLoaded(ITask task)
        {
            if (task.IsOk)
            {
                WWWFileLoadTask t = task as WWWFileLoadTask;

                if (DoChecWriteNewVersion(t.ByteData))
                {
                    FileStream stream = new FileStream(m_VersionName, FileMode.Create, FileAccess.Write);
                    try
                    {
                        stream.Write(t.ByteData, 0, t.ByteData.Length);
                    } finally
                    {
                        stream.Close();
                        stream.Dispose();
                        stream = null;
                    }
                }
            }

            DoCopyFileList();
        }
Exemple #15
0
    void RefMapUpdate()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        float curTime = Time.unscaledTime;

        m_IsUPdateData = curTime - m_LastUpdateTime > 0.25f;

        if (m_IsUPdateData)
        {
            m_LastUpdateTime = curTime;
        }

        if (m_IsUPdateData)
        {
            bool isChg = UpdateAssetRefMap();

            int cnt = TimerMgr.Instance.TimerPoolCount;
            if (cnt != m_LastTimeCnt)
            {
                m_LastTimeCnt = cnt;
                isChg         = true;
            }

            cnt = ResourceAssetCache.GetPoolCount();
            if (cnt != m_LastResCacheCnt)
            {
                m_LastResCacheCnt = cnt;
                isChg             = true;
            }

            cnt = AssetBundleCache.GetPoolCount();
            if (cnt != m_LastBundleCacheCnt)
            {
                m_LastBundleCacheCnt = cnt;
                isChg = true;
            }

#if UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2018 || UNITY_2019
            cnt = BundleCreateAsyncTask.GetPoolCount();
            if (cnt != m_LastBundleCreateCnt)
            {
                m_LastBundleCreateCnt = cnt;
                isChg = true;
            }
                        #endif

            cnt = WWWFileLoadTask.GetPoolCount();
            if (cnt != m_LastWWWCreateCnt)
            {
                m_LastWWWCreateCnt = cnt;
                isChg = true;
            }

            cnt = HttpHelper.RunCount;
            if (cnt != m_LastRunHttpCnt)
            {
                m_LastRunHttpCnt = cnt;
                isChg            = true;
            }

            cnt = HttpHelper.PoolCount;
            if (cnt != m_LastHttpPoolCnt)
            {
                m_LastHttpPoolCnt = cnt;
                isChg             = true;
            }

            if (isChg)
            {
                this.Repaint();
            }
        }
    }
Exemple #16
0
        private void CopyVersion()
        {
            WWWFileLoadTask task = AutoUpdateMgr.Instance.CreateWWWStreamAssets(AutoUpdateMgr._cVersionTxt, true);

            task.AddResultEvent(OnVersionLoaded);
        }
Exemple #17
0
        private void CopyFileList()
        {
            WWWFileLoadTask task = AutoUpdateMgr.Instance.CreateWWWStreamAssets(AutoUpdateMgr._cFileListTxt, true);

            task.AddResultEvent(OnFileListloaded);
        }