ソースを参照

DotNet Init改成跟Unity中类似

tanghai 3 年 前
コミット
5fc73b8dca

+ 19 - 1
DotNet/App/Program.cs

@@ -1,4 +1,7 @@
-namespace ET
+using System;
+using System.Threading;
+
+namespace ET
 {
     public static class Program
     {
@@ -13,6 +16,21 @@
             //的组件可以写在Core中
             Entry.Init();
             Init.Start();
+            
+            while (true)
+            {
+                Thread.Sleep(1);
+                try
+                {
+                    Init.Update();
+                    Init.LateUpdate();
+                    Init.FrameFinishUpdate();
+                }
+                catch (Exception e)
+                {
+                    Log.Error(e);
+                }
+            }
         }
     }
 }

+ 15 - 16
DotNet/Loader/Init.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Threading;
 using CommandLine;
 
 namespace ET
@@ -36,26 +35,26 @@ namespace ET
 				Log.Console($"{Parser.Default.FormatCommandLine(Options.Instance)}");
 
 				Game.AddSingleton<CodeLoader>().Start();
-
-				while (true)
-				{
-					try
-					{
-						Thread.Sleep(1);
-						Game.Update();
-						Game.LateUpdate();
-						Game.FrameFinishUpdate();
-					}
-					catch (Exception e)
-					{
-						Log.Error(e);
-					}
-				}
 			}
 			catch (Exception e)
 			{
 				Log.Error(e);
 			}
 		}
+
+		public static void Update()
+		{
+			Game.Update();
+		}
+
+		public static void LateUpdate()
+		{
+			Game.LateUpdate();
+		}
+
+		public static void FrameFinishUpdate()
+		{
+			Game.FrameFinishUpdate();
+		}
 	}
 }

+ 0 - 15
Unity/Assets/Scripts/Core/Helper/MathHelper.cs

@@ -1,15 +0,0 @@
-namespace ET
-{
-    public static class MathHelper
-    {
-        public static float RadToDeg(float radians)
-        {
-            return (float)(radians * 180 / System.Math.PI);
-        }
-        
-        public static float DegToRad(float degrees)
-        {
-            return (float)(degrees * System.Math.PI / 180);
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/Helper/MathHelper.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e1b7e8db0b79be040b4b9a35008a9018
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: