diff --git a/README.md b/README.md index 024d631..e6b2598 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Current ported to commit: [![加入QQ群](https://img.shields.io/badge/QQ%20Group-加入QQ群-orange)](https://jq.qq.com/?_wv=1027&k=b2zyTWnZ) # Unity test -Run link.bat to link source code to Unity project +Run `CopyToUnityTestbed.bat` to copy source code and test code to Unity project # Testbed Driven by [OpenTk](https://github.com/opentk/opentk) + [ImGui.NET](https://github.com/mellinoe/imgui.net) diff --git a/test/UnityTest/Assembly-CSharp.csproj b/test/UnityTest/Assembly-CSharp.csproj index ba466bd..03eec31 100644 --- a/test/UnityTest/Assembly-CSharp.csproj +++ b/test/UnityTest/Assembly-CSharp.csproj @@ -251,9 +251,6 @@ - - - diff --git a/test/UnityTest/Assets/Game.cs b/test/UnityTest/Assets/Game.cs index a3fcaec..93a7e92 100644 --- a/test/UnityTest/Assets/Game.cs +++ b/test/UnityTest/Assets/Game.cs @@ -136,6 +136,11 @@ public void Update() CheckMouseUp(); } + private void OnPreRender() + { + Test.Render(); + } + private void OnEnable() { ImGuiUn.Layout += RenderUI; diff --git a/test/UnityTest/Assets/Inspection/BoundBase.cs b/test/UnityTest/Assets/Inspection/BoundBase.cs deleted file mode 100644 index 963d411..0000000 --- a/test/UnityTest/Assets/Inspection/BoundBase.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -namespace Box2DSharp.Testbed.Unity.Inspection -{ - [ExecuteInEditMode] - public abstract class BoundBase : MonoBehaviour - { - private const string MainCameraTag = "MainCamera"; - - private UnityDrawer _unityDrawer; - - /// - /// Line color - /// - public Color Color = Color.green; - - /// - /// Hide Line - /// - public bool Hide; - - /// - /// Bound name - /// - public string Name; - - // Update is called once per frame - private void LateUpdate() - { - if (Hide) - { - return; - } - - if (_unityDrawer == default) - { - _unityDrawer = UnityDrawer.GetDrawer(); - } - - _unityDrawer.PostLines(DrawLine(), Color); - } - - protected abstract List<(Vector3 begin, Vector3 end)> DrawLine(); - } -} \ No newline at end of file diff --git a/test/UnityTest/Assets/Inspection/BoundBase.cs.meta b/test/UnityTest/Assets/Inspection/BoundBase.cs.meta deleted file mode 100644 index c5494d7..0000000 --- a/test/UnityTest/Assets/Inspection/BoundBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 845311659c609984ca3d8c1aa1cd70b4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/test/UnityTest/Assets/Inspection/BoundCircle.cs b/test/UnityTest/Assets/Inspection/BoundCircle.cs deleted file mode 100644 index 59c6dd1..0000000 --- a/test/UnityTest/Assets/Inspection/BoundCircle.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace Box2DSharp.Testbed.Unity.Inspection -{ - public class BoundCircle : BoundBase - { - public Vector2 Center = Vector2.zero; - - /// - /// Circle edge line count, the greater the more accuracy - /// - public int LineCount = 100; - - public float Radius = 1f; - - public bool TransformBased = true; - - public bool TransformCircumcircle = true; - - // Update is called once per frame - protected override List<(Vector3, Vector3)> DrawLine() - { - if (TransformBased) - { - Center = transform.position; - } - - if (TransformCircumcircle) - { - Radius = (float) Math.Sqrt( - Math.Pow(transform.localScale.x, 2) + Math.Pow(transform.localScale.y, 2)) - / 2; - } - - var lines = new List<(Vector3, Vector3)>(); - - for (var i = 0; i <= LineCount; ++i) //割圆术画圆 - { - lines.Add( - ( - new Vector2( - Center.x + Radius * Mathf.Cos(2 * Mathf.PI / LineCount * i), - Center.y + Radius * Mathf.Sin(2 * Mathf.PI / LineCount * i)), - new Vector2( - Center.x + Radius * Mathf.Cos(2 * Mathf.PI / LineCount * (i + 1)), - Center.y + Radius * Mathf.Sin(2 * Mathf.PI / LineCount * (i + 1))) - )); - } - - return lines; - } - } -} \ No newline at end of file diff --git a/test/UnityTest/Assets/Inspection/BoundCircle.cs.meta b/test/UnityTest/Assets/Inspection/BoundCircle.cs.meta deleted file mode 100644 index 0abae4d..0000000 --- a/test/UnityTest/Assets/Inspection/BoundCircle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1a5925e9235547848868d9c0bffa6f25 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/test/UnityTest/Assets/Inspection/BoundRect.cs b/test/UnityTest/Assets/Inspection/BoundRect.cs deleted file mode 100644 index c05566f..0000000 --- a/test/UnityTest/Assets/Inspection/BoundRect.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -namespace Box2DSharp.Testbed.Unity.Inspection -{ - public class BoundRect : BoundBase - { - public Vector2 BottomLeft; - - public Vector2 BottomRight; - - public Vector2 Max; - - public Vector2 Min; - - public Vector2 TopLeft; - - public Vector2 TopRight; - - public bool TransformBased = true; - - /// - protected override List<(Vector3, Vector3)> DrawLine() - { - if (TransformBased) - { - var x = transform.position.x; - var y = transform.position.y; - var hw = transform.localScale.x / 2; - var hh = transform.localScale.y / 2; - - BottomLeft = new Vector2(x - hw, y - hh); - TopLeft = new Vector2(x - hw, y + hh); - TopRight = new Vector2(x + hw, y + hh); - BottomRight = new Vector2(x + hw, y - hh); - } - else - { - BottomLeft = Min; - TopLeft = new Vector2(Min.x, Max.y); - TopRight = Max; - BottomRight = new Vector2(Max.x, Min.y); - } - - var lines = new List<(Vector3, Vector3)> - { - (BottomLeft, TopLeft), - (TopLeft, TopRight), - (TopRight, BottomRight), - (BottomRight, BottomLeft) - }; - - // GL.Begin(GL.LINE_STRIP); - // GL.Color(Color); - // GL.Vertex(BottomLeft); - // GL.Vertex(TopLeft); - // GL.Vertex(TopRight); - // GL.Vertex(BottomRight); - // GL.Vertex(BottomLeft); - - // GL.End(); - return lines; - } - } -} \ No newline at end of file diff --git a/test/UnityTest/Assets/Inspection/BoundRect.cs.meta b/test/UnityTest/Assets/Inspection/BoundRect.cs.meta deleted file mode 100644 index 6fa9307..0000000 --- a/test/UnityTest/Assets/Inspection/BoundRect.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e4f3c0ef778d92c4c8f3e782cdd15aaf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/test/UnityTest/Assets/System.Buffers.dll b/test/UnityTest/Assets/System.Buffers.dll index b6d9c77..c0970c0 100644 Binary files a/test/UnityTest/Assets/System.Buffers.dll and b/test/UnityTest/Assets/System.Buffers.dll differ diff --git a/test/UnityTest/Assets/System.Buffers.dll.meta b/test/UnityTest/Assets/System.Buffers.dll.meta index 3078b30..3909278 100644 --- a/test/UnityTest/Assets/System.Buffers.dll.meta +++ b/test/UnityTest/Assets/System.Buffers.dll.meta @@ -9,6 +9,7 @@ PluginImporter: isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 + validateReferences: 1 platformData: - first: Any: diff --git a/test/UnityTest/Assets/System.Memory.dll b/test/UnityTest/Assets/System.Memory.dll index 2d54316..078aa55 100644 Binary files a/test/UnityTest/Assets/System.Memory.dll and b/test/UnityTest/Assets/System.Memory.dll differ diff --git a/test/UnityTest/Assets/System.Memory.dll.meta b/test/UnityTest/Assets/System.Memory.dll.meta index e92b254..6cabee6 100644 --- a/test/UnityTest/Assets/System.Memory.dll.meta +++ b/test/UnityTest/Assets/System.Memory.dll.meta @@ -9,6 +9,7 @@ PluginImporter: isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 + validateReferences: 1 platformData: - first: Any: diff --git a/test/UnityTest/Assets/System.Runtime.CompilerServices.Unsafe.dll b/test/UnityTest/Assets/System.Runtime.CompilerServices.Unsafe.dll deleted file mode 100644 index 3156239..0000000 Binary files a/test/UnityTest/Assets/System.Runtime.CompilerServices.Unsafe.dll and /dev/null differ diff --git a/test/UnityTest/Assets/System.Runtime.CompilerServices.Unsafe.dll.meta b/test/UnityTest/Assets/System.Runtime.CompilerServices.Unsafe.dll.meta deleted file mode 100644 index baf700f..0000000 --- a/test/UnityTest/Assets/System.Runtime.CompilerServices.Unsafe.dll.meta +++ /dev/null @@ -1,69 +0,0 @@ -fileFormatVersion: 2 -guid: 4d3834ee8b5657541839927fdea9f34c -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - CPU: AnyCPU - DefaultValueInitialized: true - OS: AnyOS - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: OSXUniversal - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/test/UnityTest/Packages/manifest.json b/test/UnityTest/Packages/manifest.json new file mode 100644 index 0000000..d9a1588 --- /dev/null +++ b/test/UnityTest/Packages/manifest.json @@ -0,0 +1,44 @@ +{ + "dependencies": { + "com.realgames.dear-imgui": "https://github.com/realgamessoftware/dear-imgui-unity.git", + "com.unity.collab-proxy": "1.2.16", + "com.unity.ide.rider": "1.1.4", + "com.unity.ide.vscode": "1.2.1", + "com.unity.inputsystem": "1.0.1", + "com.unity.test-framework": "1.1.14", + "com.unity.textmeshpro": "2.0.1", + "com.unity.timeline": "1.2.15", + "com.unity.ugui": "1.0.0", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/test/UnityTest/Packages/packages-lock.json b/test/UnityTest/Packages/packages-lock.json new file mode 100644 index 0000000..ccb9397 --- /dev/null +++ b/test/UnityTest/Packages/packages-lock.json @@ -0,0 +1,363 @@ +{ + "dependencies": { + "com.realgames.dear-imgui": { + "version": "https://github.com/realgamessoftware/dear-imgui-unity.git", + "depth": 0, + "source": "git", + "dependencies": { + "com.unity.collections": "0.5.0-preview.9" + }, + "hash": "561339c07f940a0238c43d6cc77c1836373f7fa9" + }, + "com.unity.burst": { + "version": "1.2.0-preview.11", + "depth": 2, + "source": "registry", + "dependencies": { + "com.unity.mathematics": "1.1.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.collab-proxy": { + "version": "1.2.16", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.collections": { + "version": "0.5.0-preview.9", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.test-framework.performance": "1.3.3-preview", + "com.unity.burst": "1.2.0-preview.11" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.ext.nunit": { + "version": "1.0.0", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.ide.rider": { + "version": "1.1.4", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.1" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.ide.vscode": { + "version": "1.2.1", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.inputsystem": { + "version": "1.0.1", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.mathematics": { + "version": "1.1.0", + "depth": 3, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.test-framework": { + "version": "1.1.14", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.test-framework.performance": { + "version": "1.3.3-preview", + "depth": 2, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.textmeshpro": { + "version": "2.0.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.timeline": { + "version": "1.2.15", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.ugui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0" + } + }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.androidjni": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.animation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.assetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.audio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.cloth": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.director": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.animation": "1.0.0" + } + }, + "com.unity.modules.imageconversion": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.imgui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.jsonserialize": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.screencapture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.subsystems": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.terrain": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, + "com.unity.modules.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics2d": "1.0.0" + } + }, + "com.unity.modules.ui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.uielements": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.umbra": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unityanalytics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.unitywebrequest": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unitywebrequestassetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestaudio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.audio": "1.0.0" + } + }, + "com.unity.modules.unitywebrequesttexture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestwww": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.vehicles": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.video": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.vr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } + }, + "com.unity.modules.wind": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.xr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.subsystems": "1.0.0" + } + } + } +} diff --git a/test/UnityTest/ProjectSettings/ProjectSettings.asset b/test/UnityTest/ProjectSettings/ProjectSettings.asset index 5b386f2..5806001 100644 --- a/test/UnityTest/ProjectSettings/ProjectSettings.asset +++ b/test/UnityTest/ProjectSettings/ProjectSettings.asset @@ -549,14 +549,14 @@ PlayerSettings: 1: IMGUI_FEATURE_CUSTOM_ASSERT;IMGUI_FEATURE_FREETYPE platformArchitecture: {} scriptingBackend: - Standalone: 1 + Standalone: 0 il2cppCompilerConfiguration: {} managedStrippingLevel: {} incrementalIl2cppBuild: {} allowUnsafeCode: 1 additionalIl2CppArgs: scriptingRuntimeVersion: 1 - gcIncremental: 0 + gcIncremental: 1 gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: {} m_RenderingPath: 1