diff options
Diffstat (limited to 'Box2d/Assets/Program/Test')
-rw-r--r-- | Box2d/Assets/Program/Test/ApplicationMain.cs | 40 | ||||
-rw-r--r-- | Box2d/Assets/Program/Test/ApplicationMain.cs.meta | 11 | ||||
-rw-r--r-- | Box2d/Assets/Program/Test/DontDestroyOnLoad.cs | 13 | ||||
-rw-r--r-- | Box2d/Assets/Program/Test/DontDestroyOnLoad.cs.meta | 11 |
4 files changed, 75 insertions, 0 deletions
diff --git a/Box2d/Assets/Program/Test/ApplicationMain.cs b/Box2d/Assets/Program/Test/ApplicationMain.cs new file mode 100644 index 0000000..bec4540 --- /dev/null +++ b/Box2d/Assets/Program/Test/ApplicationMain.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Box2DX; +using Box2DX.Dynamics; +using Box2DX.Collision; +using Box2DX.Common; + +public class ApplicationMain : MonoBehaviour +{ + + + public Material material; + + void OnPostRender() + { + //绘制正四边形,提供的坐标必须是顺时针或者逆时针 + Draw(100, 100, 100, 200, 200, 200, 200, 100); + //绘制无规则四边形 + Draw(15, 5, 10, 115, 95, 110, 90, 10); + } + + //绘制四边形,四个点坐标 + void Draw(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) + { + GL.PushMatrix(); + //material.SetPass(0);//设置该材质通道,0为默认值 + GL.LoadOrtho();//设置绘制2d图像 + GL.Begin(GL.QUADS);//绘制类型为四边形 + + GL.Vertex3(x1 / Screen.width, y1 / Screen.height, 0); + GL.Vertex3(x2 / Screen.width, y2 / Screen.height, 0); + GL.Vertex3(x3 / Screen.width, y3 / Screen.height, 0); + GL.Vertex3(x4 / Screen.width, y4 / Screen.height, 0); + + GL.End(); + GL.PopMatrix(); + } + +} diff --git a/Box2d/Assets/Program/Test/ApplicationMain.cs.meta b/Box2d/Assets/Program/Test/ApplicationMain.cs.meta new file mode 100644 index 0000000..0b20af6 --- /dev/null +++ b/Box2d/Assets/Program/Test/ApplicationMain.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2dc4697d525f9454e9497e4fc4ac0a66 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Box2d/Assets/Program/Test/DontDestroyOnLoad.cs b/Box2d/Assets/Program/Test/DontDestroyOnLoad.cs new file mode 100644 index 0000000..0ea2e7f --- /dev/null +++ b/Box2d/Assets/Program/Test/DontDestroyOnLoad.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DontDestroyOnLoad : MonoBehaviour +{ + + private void Awake() + { + DontDestroyOnLoad(gameObject); + } + +} diff --git a/Box2d/Assets/Program/Test/DontDestroyOnLoad.cs.meta b/Box2d/Assets/Program/Test/DontDestroyOnLoad.cs.meta new file mode 100644 index 0000000..579b1fd --- /dev/null +++ b/Box2d/Assets/Program/Test/DontDestroyOnLoad.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc2944ec2555cbb4f831f0702cc76c95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |