How to make the script wait/sleep in a simple way in unity

前端 未结 5 1816
情话喂你
情话喂你 2020-11-22 12:03

How can I put a sleep function between the TextUI.text = ...., to wait 3 seconds between each phrase?

public Text GuessUI;
public Text TextUI;
         


        
5条回答
  •  太阳男子
    2020-11-22 12:39

    you can

            float Lasttime;
            public float Sec = 3f;
            public int Num;
            void Start(){
            ExampleStart();
            }
            public void ExampleStart(){
            Lasttime = Time.time;
            }
            void Update{
    
            if(Time.time - Lasttime > sec){
    //           if(Num == step){
    //             Yourcode
    //You Can Change Sec with => sec = YOURTIME(Float)
    //             Num++;
    //            ExampleStart();
                 }
                 if(Num == 0){
                 TextUI.text = "Welcome to Number Wizard!";
                 Num++;
                 ExampleStart();
                 }
                 if(Num == 1){
                 TextUI.text = ("The highest number you can pick is " + max);
                 Num++;
                 ExampleStart();
                 }
                 if(Num == 2){
                 TextUI.text = ("The lowest number you can pick is " + min);
                 Num++;
                 ExampleStart();
                 }
            }
    
        }  
    

    Khaled Developer
    Easy For Gaming

提交回复
热议问题