Skip to content

final commit for JEngine v0.7.5 #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public int[] GetVersion(string bundlePackageName)
{
if (AssetComponentConfig.AssetLoadMode != AssetLoadMode.Build)
{
AssetLogHelper.LogError("仅Build模式可用获取版本索引");
AssetLogHelper.Log("仅Build模式可用获取版本索引");
return null;
}
if (!PackageToVersion.TryGetValue(bundlePackageName, out int[] versionData))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ private static async Task Wait(float time, CancellationToken token, GameObject g
//当计时器的时间小于暂停时间转毫秒除以时间系数时,等待1帧
if (Time.timeScale == 0 || sw.ElapsedMilliseconds < (time * 1000) / Time.timeScale)
{
await TimeMgr.Delay(1);
await Task.Delay(1);
}
else //不满足条件就结束了
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void Start()

public async void SetText()
{
await TimeMgr.Delay(100);
await Task.Delay(100);
text.text = Localization.GetString(key);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ public static async void LoadSceneAsync(string path, bool additive = false, stri
while (!operation.isDone && operation.progress < 0.9f)
{
loadingCallback?.Invoke(operation.progress);
await TimeMgr.Delay(1);
await Task.Delay(1);
}

loadingCallback?.Invoke(1);
await TimeMgr.Delay(30);//1/30秒的时间去刷新UI
await Task.Delay(30);//1/30秒的时间去刷新UI
operation.allowSceneActivation = true;
operation.completed += asyncOperation =>
{
Expand Down
52 changes: 0 additions & 52 deletions UnityProject/Assets/Dependencies/JEngine/Core/Manager/TimeMgr.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static void BuildAssetBundles()

Setting.EncryptPassword = s;

await TimeMgr.Delay(3);
await Task.Delay(3);
AssetDatabase.Refresh();

watch = new Stopwatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static async Task OnEnable(AnimBool[] fadeGroup, UnityAction repaint)
//ignored
}

await TimeMgr.Delay(500);
await Task.Delay(500);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static async void CleanFields(ClassBind instance, bool toast = true)
field.fieldName, data.fields.IndexOf(field), data.fields.Length),
data.fields.IndexOf(field) / (float) data.fields.Length);

await TimeMgr.Delay(50); //延迟一下,动画更丝滑
await Task.Delay(50); //延迟一下,动画更丝滑
}

var f = data.fields.OrderBy(s => s.fieldName);
Expand Down Expand Up @@ -211,7 +211,7 @@ public static async void DoFieldType(ClassBind instance, bool toast = true)
field.fieldName, data.fields.IndexOf(field), data.fields.Length),
data.fields.IndexOf(field) / (float) data.fields.Length);

await TimeMgr.Delay(50); //延迟一下,动画更丝滑
await Task.Delay(50); //延迟一下,动画更丝滑
}

}
Expand Down Expand Up @@ -315,11 +315,11 @@ public static async void DoConvert(ClassBind instance, bool toast = true)
affectCounts++;
}

await TimeMgr.Delay(10); //延迟一下,动画更丝滑
await Task.Delay(10); //延迟一下,动画更丝滑
}
}

await TimeMgr.Delay(50); //延迟一下,动画更丝滑
await Task.Delay(50); //延迟一下,动画更丝滑

EditorUtility.ClearProgressBar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static async void DoChange()
while (SceneManager.GetActiveScene().name != name)
{
if (!Application.isPlaying) return;
await TimeMgr.Delay(10);
await Task.Delay(10);
}
DynamicGI.UpdateEnvironment();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static async Task<string> Post(string url, Dictionary<string, string> dic
throw new TimeoutException("Post request time out");
}
timeout--;
await TimeMgr.Delay(1);
await Task.Delay(1);
}
return result;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ private static async void Pop(string title, string info)
while (isPopping)
{
EditorUtility.DisplayProgressBar(title, info, Random.Range(0f, 1f));
await TimeMgr.Delay(1);
await Task.Delay(1);
}

EditorUtility.ClearProgressBar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private async void RunSocketThread(object obj)
{
if (webSocket.IsConnected || !inGame)
{
await TimeMgr.Delay(config.reconnectDelay);
await Task.Delay(config.reconnectDelay);
}
else
{
Expand All @@ -451,7 +451,7 @@ private async void RunPingThread(object obj)
{
if (!wsConnected)
{
await TimeMgr.Delay(
await Task.Delay(
config.reconnectDelay);
}
else
Expand All @@ -465,15 +465,15 @@ await TimeMgr.Delay(
while (webSocket.IsConnected && thPinging &&
(DateTime.Now.Subtract(pingStart).TotalSeconds < timeoutMilis))
{
await TimeMgr.Delay(200);
await Task.Delay(200);
}

if (!thPong)
{
webSocket.Close();
}

await TimeMgr.Delay(intervalMilis);
await Task.Delay(intervalMilis);
}
}
}
Expand Down Expand Up @@ -566,7 +566,7 @@ private async Task<bool> EmitPacketAsync(Packet packet)

while (wsConnected && !complete)
{
await TimeMgr.Delay(10);
await Task.Delay(10);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
while (Application.isPlaying && !_destoryed && !gameObject.activeInHierarchy)
{
await JEngine.Core.TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down Expand Up @@ -92,7 +92,7 @@
{
while (Application.isPlaying && !awaked)
{
await TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async void Awake()
{
while (Application.isPlaying && !_destoryed && !gameObject.activeInHierarchy)
{
await TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down
4 changes: 2 additions & 2 deletions UnityProject/Assets/Scripts/Adapters/GenericExampleAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async void Awake()
{
while (Application.isPlaying && !destoryed && !gameObject.activeInHierarchy)
{
await JEngine.Core.TimeMgr.Delay(20);
await System.Threading.Tasks.Task.Delay(20);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down Expand Up @@ -1400,7 +1400,7 @@ public async void Awake()
{
while (Application.isPlaying && !destoryed && !gameObject.activeInHierarchy)
{
await JEngine.Core.TimeMgr.Delay(20);
await Task.Delay(20);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down
4 changes: 2 additions & 2 deletions UnityProject/Assets/Scripts/Adapters/MonoBehaviourAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async void Awake()
{
while (Application.isPlaying && !_destoryed && !gameObject.activeInHierarchy)
{
await TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down Expand Up @@ -198,7 +198,7 @@ async void OnEnable()
{
while (Application.isPlaying && !awaked)
{
await TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async void Awake()
{
while (Application.isPlaying && !_destoryed && !gameObject.activeInHierarchy)
{
await JEngine.Core.TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down Expand Up @@ -107,7 +107,7 @@ async void OnEnable()
{
while (Application.isPlaying && !awaked)
{
await TimeMgr.Delay(1);
await System.Threading.Tasks.Task.Delay(1);
}
}
catch (MissingReferenceException) //如果gameObject被删了,就会触发这个,这个时候就直接return了
Expand Down
8 changes: 4 additions & 4 deletions UnityProject/HotUpdateScripts/JEngine/Core/JAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private async ET.ETTask<JAction> Do(bool onMainThread)
//Delay
if (_item.delays.ContainsKey(_index))
{
await JEngine.Core.TimeMgr.Delay((int)(_item.delays[_index] * 1000));
await Task.Delay((int)(_item.delays[_index] * 1000));
continue;
}

Expand All @@ -413,7 +413,7 @@ private async ET.ETTask<JAction> Do(bool onMainThread)
//计算1帧时间(ms)
var durationPerFrame = 1000 / (int)(Application.targetFrameRate <= 0 ? GameStats.FPS : Application.targetFrameRate);
var duration = durationPerFrame * _item.delayFrames[_index];
await JEngine.Core.TimeMgr.Delay(duration);
await Task.Delay(duration);
continue;
}

Expand All @@ -435,7 +435,7 @@ private async ET.ETTask<JAction> Do(bool onMainThread)
throw new TimeoutException();
}

await JEngine.Core.TimeMgr.Delay((int)(_item.frequency[_index] * 1000));
await Task.Delay((int)(_item.frequency[_index] * 1000));
time += _item.frequency[_index];
}
continue;
Expand Down Expand Up @@ -477,7 +477,7 @@ await Task.Run(() =>
await Task.Run(action, _item.cancellationTokenSource.Token);
}

await JEngine.Core.TimeMgr.Delay((int)(frequency * 1000));
await Task.Delay((int)(frequency * 1000));
time += frequency;
}
continue;
Expand Down
7 changes: 4 additions & 3 deletions UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace JEngine.Core
{
Expand Down Expand Up @@ -155,7 +156,7 @@ private static async void JBehavioursLoop()
for(; ; )
{
if (!Application.isPlaying) break;
await TimeMgr.Delay(1);
await Task.Delay(1);
int cnt = LoopJBehaviours.Count;
for (int i = 0; i < cnt; i++)
{
Expand Down Expand Up @@ -549,7 +550,7 @@ public JBehaviour Activate()
int duration;
duration = (int)((1f / ((float)Application.targetFrameRate <= 0 ? GameStats.FPS : Application.targetFrameRate)) * 1000f);
duration = (int)(duration / TimeScale);
await TimeMgr.Delay(duration);
await Task.Delay(duration);
OnEnable();
Start();
});
Expand All @@ -572,7 +573,7 @@ private protected async void Launch()
break;
}

await JEngine.Core.TimeMgr.Delay(1);
await Task.Delay(1);
}

if (JBehaviours is null || _gameObject is null)
Expand Down
4 changes: 2 additions & 2 deletions UnityProject/HotUpdateScripts/JEngine/Core/JPrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public async Task WaitForAsyncLoading()
{
if (!AssetMgr.RuntimeMode)
{
await JEngine.Core.TimeMgr.Delay(1);
await Task.Delay(1);
while (!Loaded)
{
await JEngine.Core.TimeMgr.Delay(10);
await Task.Delay(10);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override async void Init()
//取消注册ExtensionManager,这样下次不会post到这个实例内的方法
JEvent.defaultEvent.Unregister(ExtensionManager);

await JEngine.Core.TimeMgr.Delay(3000);
await Task.Delay(3000);

//创建独立的JEvent
JEvent e = new JEvent();
Expand Down