Skip to content

Commit

Permalink
optimized JBehaviour loop + fixed nino demo error
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonXuDeveloper committed Dec 5, 2022
1 parent 6053341 commit 9764bb5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
8 changes: 5 additions & 3 deletions UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private static async void JBehavioursLoop()
{
Stopwatch sw = new Stopwatch();
JBehaviour jb;
float duration, time;
for(; ; )
{
if (!Application.isPlaying) break;
Expand All @@ -177,7 +178,6 @@ private static async void JBehavioursLoop()
jb.Frequency = 1;
}

int duration;
if (jb.FrameMode)//等待
{
duration = (int)(jb.Frequency / ((float)Application.targetFrameRate <= 0 ? GameStats.FPS : Application.targetFrameRate) * 1000f);
Expand All @@ -193,7 +193,9 @@ private static async void JBehavioursLoop()
duration = 1;
}

if (Time.realtimeSinceStartup - jb.CurTime < duration / 1000f)
duration /= 1000f;

if (Time.realtimeSinceStartup - jb.CurTime < duration)
{
continue;
}
Expand All @@ -215,7 +217,7 @@ private static async void JBehavioursLoop()
sw.Stop();

//操作时间
var time = sw.ElapsedMilliseconds / 1000f + duration / 1000f + 0.001f;
time = sw.ElapsedMilliseconds / 1000f + 0.001f + duration;
jb.LoopCounts++;
jb.LoopDeltaTime = time;
jb.TotalTime += time;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Awake()
});
_list.Add(new NinoTestData
{
sex = NinoTestData.Sex.Male,
sex = NinoTestData.Sex.Female,
name = "B",
id = 1,
isHasPet = true
Expand Down Expand Up @@ -93,7 +93,7 @@ public void Awake()
};
_arr[1] = new NinoTestData
{
sex = NinoTestData.Sex.Male,
sex = NinoTestData.Sex.Female,
name = "D",
id = 3,
isHasPet = false
Expand All @@ -102,8 +102,8 @@ public void Awake()
buf = Serializer.Serialize(_arr);
Log.Print($"Nino 将_arr数据序列化为了 {buf.Length} bytes");

var _arr2 = Deserializer.Deserialize<List<NinoTestData>>(buf);
Log.Print($"Nino 反序列化了一个_arr2,内部有{_arr2.Count}个元素");
var _arr2 = Deserializer.Deserialize<NinoTestData[]> (buf);
Log.Print($"Nino 反序列化了一个_arr2,内部有{_arr2.Length}个元素");
Log.Print($"_arr2[0].sex = {_arr2[0].sex}\n" +
$"_arr2[0].name = {_arr2[0].name}\n" +
$"_arr2[0].id = {_arr2[0].id}\n" +
Expand Down

0 comments on commit 9764bb5

Please sign in to comment.