Loading 进度条加载动画效果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
public UIProgressBar loadingAnimator; AsyncOperation async; float displayProgress = 0f; float toProgress = 0f; // Use this for initialization void Start () { // 执行协程方法 StartCoroutine (loadScene()); } IEnumerator loadScene () { // 异步加载第三个场景 async = Application.LoadLevelAsync (3); yield return new WaitForEndOfFrame(); // 加载完成不自动进入 async.allowSceneActivation = false; yield return async; } void FixedUpdate () { // 因unity异步加载只加载到90% 所以判断小于等于0.9f if (async.progress <= 0.9f) toProgress = async.progress; if (displayProgress < toProgress + 0.1) displayProgress += 0.01f; loadingAnimator.value = (displayProgress); if (displayProgress >= 1) async.allowSceneActivation = true; } |
- 本文固定链接: http://www.u3d8.com/?p=126
- 转载请注明: 网虫虫 在 u3d8.com 发表过