Selaa lähdekoodia

增加帧update参数:每帧耗时(毫秒)
游戏服限帧约66fps

大爷 1 vuosi sitten
vanhempi
commit
5ad42f0cfa

+ 6 - 4
DotNet/App/Program.cs

@@ -16,15 +16,17 @@ namespace ET
             //的组件可以写在Core中
             Entry.Init();
             Init.Start();
-            
+
+            long nowMS = DateTime.Now.Ticks;
             while (true)
             {
-                Thread.Sleep(1);
+                Thread.Sleep(15);
                 try
                 {
-                    Init.Update();
+                    Init.Update((int)(DateTime.Now.Ticks - nowMS)/10000);
                     Init.LateUpdate();
                     Init.FrameFinishUpdate();
+                    nowMS = DateTime.Now.Ticks;
                 }
                 catch (Exception e)
                 {
@@ -33,4 +35,4 @@ namespace ET
             }
         }
     }
-}
+}

+ 2 - 2
DotNet/Loader/Init.cs

@@ -45,9 +45,9 @@ namespace ET
 			}
 		}
 
-		public static void Update()
+		public static void Update(int timeMS)
 		{
-			Game.Update();
+			Game.Update(timeMS);
 		}
 
 		public static void LateUpdate()

+ 3 - 3
Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 
 namespace ET
@@ -23,7 +23,7 @@ namespace ET
             this.nextFrameRun.Clear();
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             // 循环过程中会有对象继续加入队列
             while (this.nextFrameRun.Count > 0)
@@ -56,4 +56,4 @@ namespace ET
             coroutineLockQueueType.Notify(key, level);
         }
     }
-}
+}

+ 1 - 1
Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs

@@ -505,7 +505,7 @@ namespace ET
             }
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             Queue<long> queue = this.queues[(int)InstanceQueueIndex.Update];
             int count = queue.Count;

+ 2 - 2
Unity/Assets/Scripts/Core/Module/Synchronization/MainThreadSynchronizationContext.cs

@@ -13,7 +13,7 @@ namespace ET
             SynchronizationContext.SetSynchronizationContext(this.threadSynchronizationContext);
         }
         
-        public void Update()
+        public void Update(int timeMS)
         {
             this.threadSynchronizationContext.Update();
         }
@@ -28,4 +28,4 @@ namespace ET
             this.threadSynchronizationContext.Post(action);
         }
     }
-}
+}

+ 3 - 3
Unity/Assets/Scripts/Core/Module/Time/TimeInfo.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 
 namespace ET
 {
@@ -33,7 +33,7 @@ namespace ET
             this.FrameTime = this.ClientNow();
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             this.FrameTime = this.ClientNow();
         }
@@ -72,4 +72,4 @@ namespace ET
             return (d.Ticks - dt.Ticks) / 10000;
         }
     }
-}
+}

+ 2 - 2
Unity/Assets/Scripts/Core/Module/Timer/TimerComponent.cs

@@ -81,7 +81,7 @@ namespace ET
             return TimeHelper.ClientFrameTime();
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             if (this.TimeId.Count == 0)
             {
@@ -319,4 +319,4 @@ namespace ET
             return this.NewRepeatedTimerInner(time, type, args);
         }
     }
-}
+}

+ 3 - 3
Unity/Assets/Scripts/Core/Singleton/Game.cs

@@ -59,7 +59,7 @@ namespace ET
             await task;
         }
 
-        public static void Update()
+        public static void Update(int timeMS)
         {
             int count = updates.Count;
             while (count-- > 0)
@@ -79,7 +79,7 @@ namespace ET
                 updates.Enqueue(singleton);
                 try
                 {
-                    update.Update();
+                    update.Update(timeMS);
                 }
                 catch (Exception e)
                 {
@@ -137,4 +137,4 @@ namespace ET
             singletonTypes.Clear();
         }
     }
-}
+}

+ 2 - 2
Unity/Assets/Scripts/Core/Singleton/ISingletonUpdate.cs

@@ -2,6 +2,6 @@
 {
     public interface ISingletonUpdate
     {
-        void Update();
+        void Update(int timeMS);
     }
-}
+}