- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38266
- 精华
- 111
|
- public class Loading : MonoBehaviour {
-
- public UISlider progressslider;
-
- // Use this for initialization
-
- void Start () {
-
- StartCoroutine(loadScene());
-
- print (“y”);
-
- }
-
- void Update()
-
- {
-
- }
-
- IEnumerator loadScene()
-
- {
-
- print(“_x”);
-
- while (progressslider.value <1f) {
-
- print(“while”);
-
- progressslider.value+=0.01f;
-
- yield return 0;
-
- }
-
- }
复制代码 输出结构:
_x;
while;
y;
while;
while;
while;
while;
while;
while;
while;
while;
当你在循环当中加入Yield的时候,下一次他会记录这个循环,从他之前的位置继续执行,也就说:他是可以记录状态变化的,这个值的变化你可以在其他函数当中更改,
再使用wait,如果下一次执行的时候,状态值发生变化,那么就会输出不同的结果
|
|