예제 #1
0
        public void OnStart()
        {
            m_ResourceComponent = CentorPivot.This.GetComponent <ResourceComponent>();

            if (m_ResourceComponent == null)
            {
                throw new Exception("Resource component is invalid.");
            }

            m_ReadWriteVersionListFileName = Utility.Path.GetRegularPath(Path.Combine(m_ResourceComponent.ReadWritePath, ResourceRation.LocalVersionListFileName));

            m_ReadWriteVersionListBackupFileName = Utility.Text.Format("{0}.{1}", m_ReadWriteVersionListFileName, ResourceRation.BackupExtension);

            m_DownloadComponent = CentorPivot.This.GetComponent <DownloadComponent>();

            if (m_DownloadComponent == null)
            {
                throw new Exception("Download manager is invalid.");
            }

            m_DownloadComponent.DownloadStart   += OnDownloadStart;
            m_DownloadComponent.DownloadUpdate  += OnDownloadUpdate;
            m_DownloadComponent.DownloadSuccess += OnDownloadSuccess;
            m_DownloadComponent.DownloadFailure += OnDownloadFailure;
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            DownloadComponent t = target as DownloadComponent;    //下载组件

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);                                                                                              //属性字段序列化
                m_DownloadAgentHelperInfo.Draw();                                                                                                           //绘制辅助器
                m_DownloadAgentHelperCount.intValue = EditorGUILayout.IntSlider("Download Agent Helper Count", m_DownloadAgentHelperCount.intValue, 1, 16); //下载器数量
            }
            EditorGUI.EndDisabledGroup();

            float timeout = EditorGUILayout.Slider("Timeout", m_Timeout.floatValue, 0f, 120f);

            if (timeout != m_Timeout.floatValue)
            {
                if (EditorApplication.isPlaying)    //运行中修改组件的值
                {
                    t.Timeout = timeout;
                }
                else
                {
                    m_Timeout.floatValue = timeout; //非运行时修改属性序列化的值
                }
            }

            int flushSize = EditorGUILayout.DelayedIntField("Flush Size", m_FlushSize.intValue);

            if (flushSize != m_FlushSize.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.FlushSize = flushSize;
                }
                else
                {
                    m_FlushSize.intValue = flushSize;
                }
            }

            //运行时显示一些下载器数据
            if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
            {
                EditorGUILayout.LabelField("Total Agent Count", t.TotalAgentCount.ToString());
                EditorGUILayout.LabelField("Free Agent Count", t.FreeAgentCount.ToString());
                EditorGUILayout.LabelField("Working Agent Count", t.WorkingAgentCount.ToString());
                EditorGUILayout.LabelField("Waiting Agent Count", t.WaitingTaskCount.ToString());
                EditorGUILayout.LabelField("Current Speed", t.CurrentSpeed.ToString());
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            DownloadComponent t = (DownloadComponent)target;

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);
                m_DownloadAgentHelperInfo.Draw();
                m_DownloadAgentHelperCount.intValue = EditorGUILayout.IntSlider("Download Agent Helper Count", m_DownloadAgentHelperCount.intValue, 1, 16);
            }
            EditorGUI.EndDisabledGroup();

            float timeout = EditorGUILayout.Slider("Timeout", m_Timeout.floatValue, 0f, 120f);

            if (timeout != m_Timeout.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.Timeout = timeout;
                }
                else
                {
                    m_Timeout.floatValue = timeout;
                }
            }

            int flushSize = EditorGUILayout.DelayedIntField("Flush Size", m_FlushSize.intValue);

            if (flushSize != m_FlushSize.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.FlushSize = flushSize;
                }
                else
                {
                    m_FlushSize.intValue = flushSize;
                }
            }

            if (EditorApplication.isPlaying && PrefabUtility.GetPrefabType(t.gameObject) != PrefabType.Prefab)
            {
                EditorGUILayout.LabelField("Total Agent Count", t.TotalAgentCount.ToString());
                EditorGUILayout.LabelField("Free Agent Count", t.FreeAgentCount.ToString());
                EditorGUILayout.LabelField("Working Agent Count", t.WorkingAgentCount.ToString());
                EditorGUILayout.LabelField("Waiting Agent Count", t.WaitingTaskCount.ToString());
                EditorGUILayout.LabelField("Current Speed", t.CurrentSpeed.ToString());
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
예제 #4
0
        /// <summary>
        /// 设置下载管理器。
        /// </summary>
        /// <param name="downloadManager">下载管理器。</param>
        public void SetDownloadManager(DownloadComponent downloadManager)
        {
            if (downloadManager == null)
            {
                throw new Exception("Download manager is invalid.");
            }

            m_DownloadManager = downloadManager;
            m_DownloadManager.DownloadSuccess += OnDownloadSuccess;
            m_DownloadManager.DownloadFailure += OnDownloadFailure;
        }
예제 #5
0
        /// <summary>
        /// 初始化版本资源列表处理器的新实例。
        /// </summary>
        /// <param name="resourceManager">资源管理器。</param>
        public VersionListProcessorComponent(ResourceComponent resourceManager)
        {
            m_ResourceManager        = resourceManager;
            m_DownloadManager        = null;
            m_VersionListLength      = 0;
            m_VersionListHashCode    = 0;
            m_VersionListZipLength   = 0;
            m_VersionListZipHashCode = 0;

            VersionListUpdateSuccess = null;
            VersionListUpdateFailure = null;
        }
    protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);

        // 加载框架Event组件
        downloadComponent = GameEntry.GetComponent <DownloadComponent>();
        eventComponent    = GameEntry.GetComponent <EventComponent>();

        eventComponent.Subscribe(DownloadUpdateEventArgs.EventId, OnDownloadUpdate);
        eventComponent.Subscribe(DownloadSuccessEventArgs.EventId, OnDownloadSuccess);

        string m_srcUrl = "http://cdn-jiaoyu-nldmx-yidong.vas.lutongnet.com/ggly_NLDMX/NLDMX_Mobile/android/GamePrimaryT6L4.ab";
        string path     = Application.persistentDataPath + Path.DirectorySeparatorChar + "test.ab";
        int    id       = downloadComponent.AddDownload(path, m_srcUrl);

        Log.Info("start    " + id);
    }
예제 #7
0
 public void InitComponent(Transform componentRoot)
 {
     this.ComponentRoot    = componentRoot;
     DataNodeComponent     = FindAndRegisterComponent <DataNodeComponent>();
     DataTableComponent    = FindAndRegisterComponent <DataTableComponent>();
     DownloadComponent     = FindAndRegisterComponent <DownloadComponent>();
     FsmComponent          = FindAndRegisterComponent <FSMComponent>();
     ResourceComponent     = FindAndRegisterComponent <ResourceComponent>();
     SettingComponent      = FindAndRegisterComponent <SettingComponent>();
     SoundComponent        = FindAndRegisterComponent <SoundComponent>();
     TimerComponent        = FindAndRegisterComponent <TimerComponent>();
     WebComponent          = FindAndRegisterComponent <WebComponent>();
     UpdateComponent       = FindAndRegisterComponent <UpdateComponent>();
     LocalizationComponent = FindAndRegisterComponent <LocalizationComponent>();
     VideoComponent        = FindAndRegisterComponent <VideoComponent>();
     InputComponent        = FindAndRegisterComponent <InputComponent>();
     SceneComponent        = FindAndRegisterComponent <SceneComponent>();
 }
예제 #8
0
 private void ResourceUpdaterInit()
 {
     m_ApplyWaitingInfo    = new List <ApplyInfo>();
     m_UpdateWaitingInfo   = new List <UpdateInfo>();
     m_UpdateCandidateInfo = new Dictionary <ResourceName, UpdateInfo>();
     m_CachedFileSystemsForGenerateReadWriteVersionList = new SortedDictionary <string, List <int> >(StringComparer.Ordinal);
     m_CachedHashBytes                           = new byte[CachedHashBytesLength];
     m_CachedBytes                               = new byte[CachedBytesLength];
     m_DownloadComponent                         = null;
     m_CheckResourcesComplete                    = false;
     m_ApplyingResourcePackPath                  = null;
     m_ApplyingResourcePackStream                = null;
     m_UpdatingResourceGroup                     = null;
     m_GenerateReadWriteVersionListLength        = 0;
     m_CurrentGenerateReadWriteVersionListLength = 0;
     m_UpdateRetryCount                          = 3;
     m_UpdatingCount                             = 0;
     m_FailureFlag                               = false;
 }
예제 #9
0
 /// <summary>
 /// 增加下载任务(可等待)
 /// </summary>
 public static Task <bool> AwaitAddDownload(this DownloadComponent self, string downloadPath, string downloadUri)
 {
     s_DownloadTcs      = new TaskCompletionSource <bool>();
     s_DownloadSerialId = self.AddDownload(downloadPath, downloadUri);
     return(s_DownloadTcs.Task);
 }
예제 #10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            DownloadComponent t = (DownloadComponent)target;

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);
                m_DownloadAgentHelperInfo.Draw();
                m_DownloadAgentHelperCount.intValue = EditorGUILayout.IntSlider("Download Agent Helper Count", m_DownloadAgentHelperCount.intValue, 1, 16);
            }
            EditorGUI.EndDisabledGroup();

            float timeout = EditorGUILayout.Slider("Timeout", m_Timeout.floatValue, 0f, 120f);

            if (timeout != m_Timeout.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.Timeout = timeout;
                }
                else
                {
                    m_Timeout.floatValue = timeout;
                }
            }

            int flushSize = EditorGUILayout.DelayedIntField("Flush Size", m_FlushSize.intValue);

            if (flushSize != m_FlushSize.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.FlushSize = flushSize;
                }
                else
                {
                    m_FlushSize.intValue = flushSize;
                }
            }

            if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
            {
                EditorGUILayout.LabelField("Paused", t.Paused.ToString());
                EditorGUILayout.LabelField("Total Agent Count", t.TotalAgentCount.ToString());
                EditorGUILayout.LabelField("Free Agent Count", t.FreeAgentCount.ToString());
                EditorGUILayout.LabelField("Working Agent Count", t.WorkingAgentCount.ToString());
                EditorGUILayout.LabelField("Waiting Agent Count", t.WaitingTaskCount.ToString());
                EditorGUILayout.LabelField("Current Speed", t.CurrentSpeed.ToString());
                EditorGUILayout.BeginVertical("box");
                {
                    TaskInfo[] downloadInfos = t.GetAllDownloadInfos();
                    if (downloadInfos.Length > 0)
                    {
                        foreach (TaskInfo downloadInfo in downloadInfos)
                        {
                            DrawDownloadInfo(downloadInfo);
                        }

                        if (GUILayout.Button("Export CSV Data"))
                        {
                            string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, "Download Task Data.csv", string.Empty);
                            if (!string.IsNullOrEmpty(exportFileName))
                            {
                                try
                                {
                                    int      index = 0;
                                    string[] data  = new string[downloadInfos.Length + 1];
                                    data[index++] = "Download Path,Serial Id,Priority,Status";
                                    foreach (TaskInfo downloadInfo in downloadInfos)
                                    {
                                        data[index++] = Utility.Text.Format("{0},{1},{2},{3}", downloadInfo.Description, downloadInfo.SerialId.ToString(), downloadInfo.Priority.ToString(), downloadInfo.Status.ToString());
                                    }

                                    File.WriteAllLines(exportFileName, data, Encoding.UTF8);
                                    Debug.Log(Utility.Text.Format("Export download task CSV data to '{0}' success.", exportFileName));
                                }
                                catch (Exception exception)
                                {
                                    Debug.LogError(Utility.Text.Format("Export download task CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.ToString()));
                                }
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("Download Task is Empty ...");
                    }
                }
                EditorGUILayout.EndVertical();
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }