第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

C#UWP計(jì)時(shí)器替代

C#UWP計(jì)時(shí)器替代

C#
縹緲止盈 2021-03-30 17:09:27
我使用計(jì)時(shí)器在Unity(C#)中編寫了一些代碼。之后,我意識(shí)到我正在編寫的平臺(tái)UWP無法使用它們。我嘗試了諸如Threadpooltimers之類的替代方法,但無法使其正常工作。還有其他替代方法或方法可以使Threadpooltimers工作嗎?using System.Collections;using System.Collections.Generic;using System.Timers;using UnityEngine;public class Spin : MonoBehaviour {    // Use this for initialization    void Start() {}    public bool spin = false;    public float speed = 36f;    private static Timer aTimer;    private static Timer bTimer;    void StartSpin()    {        spin = true;        // Create a timer and set two full rotation intervals for demo and         //another one to adjust the movement of the object (screen).        aTimer = new System.Timers.Timer();        aTimer.Interval = 2*360/speed * 1000 - 1;        bTimer = new System.Timers.Timer();        bTimer.Interval = 360 / speed * 1000;        // Hook up the Elapsed event for the timer.         aTimer.Elapsed += OnTimedEventa;        bTimer.Elapsed += OnTimedEventb;        // Disable autoreset        aTimer.AutoReset = false;        bTimer.AutoReset = true;        // Start the timer        aTimer.Enabled = true;        bTimer.Enabled = true;    }    // At the end of Timer b, change the angle of the object (screen).    void OnTimedEventb(object bTimer, System.EventArgs e)    {        transform.Rotate(Vector3.right, 45);    }    // At the end of Timer a, stop the spin movement and stop Timer b from resetting.    void OnTimedEventa(object aTimer, System.EventArgs e)    {        spin = false;        bTimer.AutoReset = false;    }    // Update is called once per frame    void Update ()     {        transform.Rotate(Vector3.back, System.Convert.ToSingle(spin) * speed * Time.deltaTime);    }}
查看完整描述

2 回答

?
慕的地6264312

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超6個(gè)贊

使用協(xié)程或更新方法編寫一個(gè)計(jì)時(shí)器。


IEnumerator Start() {

     while (true) {

          yield return new WaitForSeconds(1.0f);

          Debug.Log("Elapsed.");

     }

}


查看完整回答
反對(duì) 回復(fù) 2021-04-10
  • 2 回答
  • 0 關(guān)注
  • 395 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)