zoukankan      html  css  js  c++  java
  • unity3d 延迟运行脚本语句

    在Unity3D中。有yield语句它负责延迟操作。yield return WaitForSeconds(3.0); //等待 3 秒
    查看unity3d脚本手冊,使用方法须要在对应的格式。
    
    以下代码含义就是,载入图片显示等待6秒后进入场景level1中。



    using UnityEngine;
    using System.Collections;
    
    public class init : MonoBehaviour {
    
    	// Use this for initialization
    	public Texture img;
    	private bool bl = false;
    	public float waitTime ;
    	void Start () {
    		StartCoroutine( wait(6.0f) );
    
    	}
    	
    	// Update is called once per frame
    	void Update () {
    		if (bl)
    			Application.LoadLevel(1);
    
    	}
    
    	void OnGUI()
    	{
    		GUI.DrawTexture(new Rect(0,0,1024,768),img);
    	}
    
    	IEnumerator wait(float time)
    	{
    		yield return new WaitForSeconds(waitTime);
    		bl = true;
    	}
    }
    



  • 相关阅读:
    Go
    Go
    Go
    Go
    Go
    Go
    爬虫常用相关库
    Go
    python基础第7天(day19)
    python基础第五天(day17)元组,集合,字符串操作 字符编码:
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/6936309.html
Copyright © 2011-2022 走看看