diff --git a/README.md b/README.md index 14f9fceb..9fbe2159 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ -# JENGINE v0.8.0f4 +# JENGINE v0.8.0f5 **JEngine is an out-of-the-box framework designed for Unity developers. It encapsulates powerful functions. Beginners can also get started quickly and easily create games that can be updated in runtime.** diff --git a/README_zh_cn.md b/README_zh_cn.md index fd04b000..635d84f6 100644 --- a/README_zh_cn.md +++ b/README_zh_cn.md @@ -30,7 +30,7 @@ -# JENGINE v0.8.0f4 +# JENGINE v0.8.0f5 JEngine是针对Unity开发者设计的**开箱即用**的框架,封装了强大的功能,小白也能**快速上手**,**轻松制作**可以**热更新的游戏** diff --git a/UnityProject/Assets/Dependencies/JEngine/Core/Manager/ClassBindMgr.cs b/UnityProject/Assets/Dependencies/JEngine/Core/Manager/ClassBindMgr.cs index bc7f3b7f..43b78ac8 100644 --- a/UnityProject/Assets/Dependencies/JEngine/Core/Manager/ClassBindMgr.cs +++ b/UnityProject/Assets/Dependencies/JEngine/Core/Manager/ClassBindMgr.cs @@ -125,6 +125,8 @@ public static void DoBind(ICollection cbs) cb.Active(data); } + + Object.Destroy(cb); } //确保任务全执行了 diff --git a/UnityProject/Assets/Dependencies/JEngine/Core/Util/ClassBind.cs b/UnityProject/Assets/Dependencies/JEngine/Core/Util/ClassBind.cs index 1cf38a6d..d45be9bf 100644 --- a/UnityProject/Assets/Dependencies/JEngine/Core/Util/ClassBind.cs +++ b/UnityProject/Assets/Dependencies/JEngine/Core/Util/ClassBind.cs @@ -496,22 +496,8 @@ public void Active(ClassData classData) { ((MonoBehaviour)clrInstance).enabled = true; classData.Activated = true; - Remove(); }); } - else - { - Remove(); - } - } - - /// - /// Remove cb - /// - private void Remove() - { - //添加后删除 - Destroy(this); } diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.dll b/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.dll index f3798bb9..11a40ccf 100644 Binary files a/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.dll and b/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.dll differ diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.pdb b/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.pdb index 694efb8e..f86eeb90 100644 Binary files a/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.pdb and b/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.pdb differ diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.bytes b/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.bytes index 21169cfc..dbeefd11 100644 Binary files a/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.bytes and b/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.bytes differ diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.pdb.bytes b/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.pdb.bytes index 694efb8e..f86eeb90 100644 Binary files a/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.pdb.bytes and b/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.pdb.bytes differ diff --git a/UnityProject/HotUpdateScripts/HotUpdateScripts.csproj b/UnityProject/HotUpdateScripts/HotUpdateScripts.csproj index 8445dbac..16cd02ec 100644 --- a/UnityProject/HotUpdateScripts/HotUpdateScripts.csproj +++ b/UnityProject/HotUpdateScripts/HotUpdateScripts.csproj @@ -68,6 +68,7 @@ + diff --git a/UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs b/UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs index da3ace15..5173eb86 100644 --- a/UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs +++ b/UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs @@ -221,7 +221,9 @@ private static string AddClassBind(GameObject gameObject, bool activeAfter, Type activeAfter = activeAfter, }; var id = ((JBehaviour)cb.AddClass(cd))._instanceID; - cb.BindSelf(); + cb.Active(cd); + UnityEngine.Object.Destroy(cb); + LifeCycleMgr.Instance.ExecuteOnceTask(); return id; } diff --git a/UnityProject/HotUpdateScripts/JEngine/Examples/Core/Test.cs b/UnityProject/HotUpdateScripts/JEngine/Examples/Core/Test.cs new file mode 100644 index 00000000..2cd0fae4 --- /dev/null +++ b/UnityProject/HotUpdateScripts/JEngine/Examples/Core/Test.cs @@ -0,0 +1,158 @@ +// +// Test.cs +// +// Author: +// JasonXuDeveloper(傑) +// +// Copyright (c) 2023 JEngine +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ILRuntime.Runtime; +using System.Diagnostics; +using Debug = UnityEngine.Debug; + +namespace HotUpdateScripts +{ + + + /// + /// 测试dll优化 + /// + public class Test + { + public void DoTest() + { + Debug.Log($"original(1) = {Original(1)}"); + Debug.Log($"jit(1) = {JIT(1)}"); + Debug.Log($"optimized(1) = {Optimized(1)}"); + Debug.Log($"optimizedJIT(1) = {OptimizedJIT(1)}"); + RunTest(10); + RunTest(100); + RunTest(1000); + RunTest(10000); + RunTest(100000); + } + + public void RunTest(int cnt = 100000) + { + Stopwatch sw = new Stopwatch(); + Debug.Log($"{cnt}次计算"); + sw.Start(); + int a = 0; + int i = cnt; + while (i-- > 0) + { + a = Original(i); + } + + sw.Stop(); + Debug.Log($"Original: {sw.ElapsedMilliseconds}ms"); + + sw.Restart(); + i = cnt; + while (i-- > 0) + { + a = JIT(i); + } + + sw.Stop(); + Debug.Log($"JIT: {sw.ElapsedMilliseconds}ms"); + + sw.Restart(); + i = cnt; + while (i-- > 0) + { + a = Optimized(i); + } + + sw.Stop(); + Debug.Log($"Optimized: {sw.ElapsedMilliseconds}ms"); + + sw.Restart(); + i = cnt; + while (i-- > 0) + { + a = OptimizedJIT(i); + } + + sw.Stop(); + Debug.Log($"OptimizedJIT: {sw.ElapsedMilliseconds}ms"); + } + + public int Original(int x) + { + int a = 5; + int b = 20; + int c = 10; + c = a; + int d = 5 * a; + int e = d; + int f = e / 2; + int g = f + a + b + c * 6 - b / 4; + int h = x * 2 + 10 + 3 - 6 - 8 - g; + return h + 10 % 3; + } + + [ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)] + public int JIT(int x) + { + int a = 5; + int b = 20; + int c = 10; + c = a; + int d = 5 * a; + int e = d; + int f = e / 2; + int g = f + a + b + c * 6 - b / 4; + int h = x * 2 + 10 + 3 - 6 - 8 - g; + return h + 10 % 3; + } + + public int Optimized(int x) + { + int a = 5; + int b = 20; + int c = 10; + c = a; + int d = 5 * a; + int e = d; + int f = e / 2; + int g = f + a + b + c * 6 - b / 4; + int h = x * 2 + 10 + 3 - 6 - 8 - g; + return h + 10 % 3; + } + + [ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)] + public int OptimizedJIT(int x) + { + int a = 5; + int b = 20; + int c = 10; + c = a; + int d = 5 * a; + int e = d; + int f = e / 2; + int g = f + a + b + c * 6 - b / 4; + int h = x * 2 + 10 + 3 - 6 - 8 - g; + return h + 10 % 3; + } + } +} + diff --git a/UnityProject/HotUpdateScripts/Program.cs b/UnityProject/HotUpdateScripts/Program.cs index 8632e21c..0c1e3116 100644 --- a/UnityProject/HotUpdateScripts/Program.cs +++ b/UnityProject/HotUpdateScripts/Program.cs @@ -23,11 +23,8 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - -using System.Diagnostics; -using ILRuntime.Runtime; using JEngine.Core; -using Debug = UnityEngine.Debug; +using UnityEngine; namespace HotUpdateScripts { @@ -55,127 +52,4 @@ public static void RunGame() //的方法一,把生成的平台改成Any CPU(默认是小写的,windows下无法生成) } } - - /// - /// 测试dll优化 - /// - public class Test - { - public void DoTest() - { - Debug.Log($"original(1) = {Original(1)}"); - Debug.Log($"jit(1) = {JIT(1)}"); - Debug.Log($"optimized(1) = {Optimized(1)}"); - Debug.Log($"optimizedJIT(1) = {OptimizedJIT(1)}"); - RunTest(10); - RunTest(100); - RunTest(1000); - RunTest(10000); - RunTest(100000); - } - - public void RunTest(int cnt = 100000) - { - Stopwatch sw = new Stopwatch(); - Debug.Log($"{cnt}次计算"); - sw.Start(); - int a = 0; - int i = cnt; - while (i-- > 0) - { - a = Original(i); - } - - sw.Stop(); - Debug.Log($"Original: {sw.ElapsedMilliseconds}ms"); - - sw.Restart(); - i = cnt; - while (i-- > 0) - { - a = JIT(i); - } - - sw.Stop(); - Debug.Log($"JIT: {sw.ElapsedMilliseconds}ms"); - - sw.Restart(); - i = cnt; - while (i-- > 0) - { - a = Optimized(i); - } - - sw.Stop(); - Debug.Log($"Optimized: {sw.ElapsedMilliseconds}ms"); - - sw.Restart(); - i = cnt; - while (i-- > 0) - { - a = OptimizedJIT(i); - } - - sw.Stop(); - Debug.Log($"OptimizedJIT: {sw.ElapsedMilliseconds}ms"); - } - - public int Original(int x) - { - int a = 5; - int b = 20; - int c = 10; - c = a; - int d = 5 * a; - int e = d; - int f = e / 2; - int g = f + a + b + c * 6 - b / 4; - int h = x * 2 + 10 + 3 - 6 - 8 - g; - return h + 10 % 3; - } - - [ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)] - public int JIT(int x) - { - int a = 5; - int b = 20; - int c = 10; - c = a; - int d = 5 * a; - int e = d; - int f = e / 2; - int g = f + a + b + c * 6 - b / 4; - int h = x * 2 + 10 + 3 - 6 - 8 - g; - return h + 10 % 3; - } - - public int Optimized(int x) - { - int a = 5; - int b = 20; - int c = 10; - c = a; - int d = 5 * a; - int e = d; - int f = e / 2; - int g = f + a + b + c * 6 - b / 4; - int h = x * 2 + 10 + 3 - 6 - 8 - g; - return h + 10 % 3; - } - - [ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)] - public int OptimizedJIT(int x) - { - int a = 5; - int b = 20; - int c = 10; - c = a; - int d = 5 * a; - int e = d; - int f = e / 2; - int g = f + a + b + c * 6 - b / 4; - int h = x * 2 + 10 + 3 - 6 - 8 - g; - return h + 10 % 3; - } - } } \ No newline at end of file diff --git a/UnityProject/UserSettings/EditorUserSettings.asset b/UnityProject/UserSettings/EditorUserSettings.asset index b1beb772..78c26ead 100644 --- a/UnityProject/UserSettings/EditorUserSettings.asset +++ b/UnityProject/UserSettings/EditorUserSettings.asset @@ -6,13 +6,13 @@ EditorUserSettings: serializedVersion: 4 m_ConfigSettings: RecentlyUsedScenePath-0: - value: 2242470311464673021a393214224b1524120b25393a25353e663c37e6cf3a69add435ece93f70283c11fb721130082beb + value: 22424703114646720307186c052d56040f flags: 0 RecentlyUsedScenePath-1: - value: 2242470311464673021a393214224b1524120b25393a25353e663032ebee7b0be1e238eca81d3e313c4cfa320d2a18 + value: 2242470311464673021a393214224b1524120b25393a25353e663c37e6cf3a69add435ece93f70283c11fb721130082beb flags: 0 RecentlyUsedScenePath-2: - value: 22424703114646720307186c052d56040f + value: 2242470311464673021a393214224b1524120b25393a25353e663032ebee7b0be1e238eca81d3e313c4cfa320d2a18 flags: 0 vcSharedLogLevel: value: 0d5e400f0650 diff --git a/package.json b/package.json index 5a929846..c81745f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.jasonxudeveloper.jengine", - "version": "0.8.0f4", + "version": "0.8.0f5", "displayName": "JEngine", "description": "The solution that allows unity games update in runtime.", "license": "MIT",