网站如何加速,深圳国际物流公司排名前十,做设计用图片的网站,进国企但是签的是外包开始尝试在项目中使用UniTask#xff0c;发现其中的UniTask.Yield确实很好用#xff0c;还可以传入PlayerLoopTiming来更细致的调整代码时机#xff0c;不过平常在Mono中接触的只有Awake#xff0c;Start#xff0c;Update等常用Timing#xff0c;其他的就没怎么接触了发现其中的UniTask.Yield确实很好用还可以传入PlayerLoopTiming来更细致的调整代码时机不过平常在Mono中接触的只有AwakeStartUpdate等常用Timing其他的就没怎么接触了虽然看名字也大概能明白但姑且还是测试一下。
测试代码
using UnityEngine;
using System;
using Cysharp.Threading.Tasks;
public class TestScript : MonoBehaviour{bool logTiming false;async UniTaskVoid TestPlayerLoop(PlayerLoopTiming timing) {await UniTask.Yield(timing);Debug.Log(${timing} - {Time.frameCount});}private void Awake() {logTiming true;foreach (PlayerLoopTiming timing in Enum.GetValues(typeof(PlayerLoopTiming))) {//跳过FixUpdate的因为触发时间可以在Setting里调整和单帧的逻辑不太一样if (timing PlayerLoopTiming.FixedUpdate) { continue;}if (timing PlayerLoopTiming.LastFixedUpdate) {continue;}TestPlayerLoop(timing).Forget();}if (logTiming) {Debug.Log($TestScript Awake - {Time.frameCount});}}private void OnEnable() {if (logTiming) {Debug.Log($TestScript OnEnable - {Time.frameCount});}}void Start(){if (logTiming) {Debug.Log($TestScript Start - {Time.frameCount});}}void Update(){if (logTiming) {Debug.Log($TestScript Update - {Time.frameCount});}}private void LateUpdate() {if (logTiming) {Debug.Log($TestScript LateUpdate - {Time.frameCount});logTiming false;}}
}
结果 和猜想也大差不差就是了