New file |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using LaunchCommon; |
| | | |
| | | public class LaunchExWin : MonoBehaviour |
| | | { |
| | | [SerializeField] Image m_BackGround; |
| | | [SerializeField] RectTransform m_AndroidProgressContainer; // 显示进度条 和平台无关 |
| | | [SerializeField] RectTransform m_IosProgressContainer; //显示转圈,ios进度条会导致审核不通过 |
| | | [SerializeField] RectTransform circleImg; |
| | | [SerializeField] RectTransform m_NetworkContainer; |
| | | [SerializeField] Text m_NetworkTip; |
| | | [SerializeField] Slider m_TotalProgressSlider; |
| | | [SerializeField] Text m_StageDescription; |
| | | [SerializeField] Text m_IosProgressTip; |
| | | [SerializeField] Text m_Version; |
| | | //预制体上的图片无法加载,通过代码加载 |
| | | [SerializeField] Image imagebg1; |
| | | [SerializeField] Image imagebg2; |
| | | [SerializeField] Image imageCircle; |
| | | [SerializeField] Image imagebg3; |
| | | [SerializeField] Image imageloding; |
| | | |
| | | |
| | | int AllTimes = 8; |
| | | bool ShowCircleView = false; |
| | | string sliderText; |
| | | |
| | | void Awake() |
| | | { |
| | | var sprite = LocalResManager.Instance.LoadSprite("Launch_1"); |
| | | m_BackGround.overrideSprite = sprite; |
| | | m_BackGround.preserveAspect = true; |
| | | sliderText = InitialFunctionConfig.Get("Language").Numerical3; |
| | | imagebg1.sprite = LocalResManager.Instance.LoadSprite("TY_TB_JH1"); |
| | | imagebg2.sprite = LocalResManager.Instance.LoadSprite("TY_TB_JH1"); |
| | | imageCircle.sprite = LocalResManager.Instance.LoadSprite("TY_TB_JH2"); |
| | | imagebg3.sprite = LocalResManager.Instance.LoadSprite("LoadingBottom"); |
| | | imageloding.sprite = LocalResManager.Instance.LoadSprite("LoadingSlider"); |
| | | } |
| | | |
| | | private void OnEnable() |
| | | { |
| | | if (m_NetworkContainer != null) |
| | | { |
| | | m_NetworkContainer.gameObject.SetActive(false); |
| | | } |
| | | m_NetworkTip.text = InitialFunctionConfig.Get("Language").Numerical4; |
| | | |
| | | var AppleCheck = InitialFunctionConfig.Get("CheckTime").Numerical1; |
| | | if (Application.platform == RuntimePlatform.IPhonePlayer && AppleCheck == "1") |
| | | ShowCircleView = true; |
| | | |
| | | if (ShowCircleView) |
| | | { |
| | | m_AndroidProgressContainer.gameObject.SetActive(false); |
| | | m_IosProgressContainer.gameObject.SetActive(true); |
| | | m_Version.text = string.Empty; |
| | | } |
| | | else |
| | | { |
| | | m_AndroidProgressContainer.gameObject.SetActive(true); |
| | | m_IosProgressContainer.gameObject.SetActive(false); |
| | | m_Version.text = StringUtility.Contact(VersionConfigEx.Get().version, "_", VersionConfigEx.Get().buildIndex, LocalResManager.Id); |
| | | } |
| | | |
| | | |
| | | UpdateProgress(); |
| | | } |
| | | |
| | | float m_Time = 0; |
| | | |
| | | void Update() |
| | | { |
| | | if (ShowCircleView) |
| | | { |
| | | circleImg.Rotate(Vector3.forward, -180 * Time.deltaTime); |
| | | } |
| | | if (Time.time - m_Time < 0.2) |
| | | { |
| | | return; |
| | | } |
| | | m_Time = Time.time; |
| | | UpdateProgress(); |
| | | |
| | | if (HttpBehaviour.ConnectAllTimes >= AllTimes && m_NetworkContainer != null) |
| | | { |
| | | m_NetworkContainer.gameObject.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | private void UpdateProgress() |
| | | { |
| | | float value; |
| | | if (LocalResManager.step == LocalResManager.LoadDllStep.None) |
| | | value = 0.05f; |
| | | else |
| | | value = DownLoadAndDiscompressTask.Instance.progress; |
| | | |
| | | if (float.IsNaN(value) || value < 0.05) |
| | | { |
| | | value = 0.05f; |
| | | } |
| | | if (ShowCircleView) |
| | | { |
| | | m_IosProgressTip.text = StringUtility.Contact(sliderText, " ", (int)(value * 100), "%"); |
| | | //circleImg.Rotate(Vector3.forward, -1800 * Time.deltaTime); |
| | | } |
| | | else |
| | | { |
| | | m_TotalProgressSlider.value = value; |
| | | m_StageDescription.text = StringUtility.Contact(sliderText, " ", (int)(value * 100), "%"); |
| | | } |
| | | |
| | | } |
| | | |
| | | public static GameObject OpenWindow() |
| | | { |
| | | GameObject window = GameObject.Instantiate(LocalResManager.Instance.LoadBuiltInPrefab("LaunchExWin")); |
| | | window.transform.localScale = Vector3.zero; |
| | | return window; |
| | | } |
| | | } |