private void StartUpdateResources(object userData) { if (m_ConfirmFormForm != null) { Object.Destroy(m_ConfirmFormForm.gameObject); m_ConfirmFormForm = null; } if (m_UpdateResourceForm == null) { m_UpdateResourceForm = Object.Instantiate(GameEntry.BuiltinData.UpdateResourceFormTemplate); } Log.Info("Start update resources..."); GameEntry.Resource.UpdateResources(OnUpdateResourcesComplete); }
protected override void OnEnter(ProcedureOwner procedureOwner) { base.OnEnter(procedureOwner); m_UpdateResourcesComplete = false; m_UpdateCount = procedureOwner.GetData <VarInt>("UpdateResourceCount"); procedureOwner.RemoveData("UpdateResourceCount"); m_UpdateTotalZipLength = procedureOwner.GetData <VarLong>("UpdateResourceTotalZipLength"); procedureOwner.RemoveData("UpdateResourceTotalZipLength"); m_UpdateSuccessCount = 0; m_UpdateLengthData.Clear(); m_UpdateResourceForm = null; m_ConfirmFormForm = null; GameEntry.Event.Subscribe(ResourceUpdateStartEventArgs.EventId, OnResourceUpdateStart); GameEntry.Event.Subscribe(ResourceUpdateChangedEventArgs.EventId, OnResourceUpdateChanged); GameEntry.Event.Subscribe(ResourceUpdateSuccessEventArgs.EventId, OnResourceUpdateSuccess); GameEntry.Event.Subscribe(ResourceUpdateFailureEventArgs.EventId, OnResourceUpdateFailure); if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork || Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { if (m_ConfirmFormForm == null) { m_ConfirmFormForm = Object.Instantiate(GameEntry.BuiltinData.ConfirmFormTemplate); m_ConfirmFormForm.SetConfirUI(new DialogParams { Mode = 2, Title = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.Title"), Message = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.Message", GetByteLengthString(m_UpdateTotalZipLength)), ConfirmText = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.UpdateButton"), OnClickConfirm = StartUpdateResources, CancelText = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.QuitButton"), OnClickCancel = delegate(object userData) { UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit); }, }); } return; } StartUpdateResources(null); }
protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown) { if (m_UpdateResourceForm != null) { Object.Destroy(m_UpdateResourceForm.gameObject); m_UpdateResourceForm = null; } if (m_ConfirmFormForm != null) { Object.Destroy(m_ConfirmFormForm.gameObject); m_ConfirmFormForm = null; } GameEntry.Event.Unsubscribe(ResourceUpdateStartEventArgs.EventId, OnResourceUpdateStart); GameEntry.Event.Unsubscribe(ResourceUpdateChangedEventArgs.EventId, OnResourceUpdateChanged); GameEntry.Event.Unsubscribe(ResourceUpdateSuccessEventArgs.EventId, OnResourceUpdateSuccess); GameEntry.Event.Unsubscribe(ResourceUpdateFailureEventArgs.EventId, OnResourceUpdateFailure); base.OnLeave(procedureOwner, isShutdown); }