-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadingController.cs
More file actions
94 lines (87 loc) · 2.67 KB
/
LoadingController.cs
File metadata and controls
94 lines (87 loc) · 2.67 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class LoadingController : MonoBehaviour {
public GameObject LoadingScreenObj;
public Slider slider;
public GameObject Button;
AsyncOperation async;
public void LaodScreenExample(string LVL)
{
StartCoroutine(LoadingScreen(LVL));
Button.SetActive(false);
}
IEnumerator LoadingScreen(string lvl)
{
LoadingScreenObj.SetActive(true);
async = SceneManager.LoadSceneAsync(lvl);
async.allowSceneActivation = false;
while(async.isDone == false)
{
slider.value = async.progress;
if (async.progress == 0.01f)
{
slider.value = 0.02f;
async.allowSceneActivation = true;
}
if (async.progress == 0.03f)
{
slider.value = 0.04f;
async.allowSceneActivation = true;
}
if (async.progress == 0.06f)
{
slider.value = 0.08f;
async.allowSceneActivation = true;
}
if (async.progress == 0.09f)
{
slider.value = 0.1f;
async.allowSceneActivation = true;
}
if (async.progress == 0.15f)
{
slider.value = 0.2f;
async.allowSceneActivation = true;
}
if (async.progress == 0.25f)
{
slider.value = 0.3f;
async.allowSceneActivation = true;
}
if (async.progress == 0.35f)
{
slider.value = 0.4f;
async.allowSceneActivation = true;
}
if (async.progress == 0.45f)
{
slider.value = 0.5f;
async.allowSceneActivation = true;
}
if (async.progress == 0.55f)
{
slider.value = 0.6f;
async.allowSceneActivation = true;
}
if (async.progress == 0.75f)
{
slider.value = 0.8f;
async.allowSceneActivation = true;
}
if (async.progress == 0.85f)
{
slider.value = 0.9f;
async.allowSceneActivation = true;
}
if (async.progress == 0.9f)
{
slider.value = 1f;
async.allowSceneActivation = true;
}
yield return null;
}
}
}