Sfoglia il codice sorgente

1.修复一个bug
2.ENABLE_VIEW功能开启

tanghai 2 anni fa
parent
commit
f263f06446

+ 0 - 4
Unity/Assets/Scripts/Core/Fiber/Fiber.cs

@@ -59,19 +59,15 @@ namespace ET
         public void Update()
         {
             this.IsRuning = true;
-            SynchronizationContext.SetSynchronizationContext(this.ThreadSynchronizationContext);
             this.ThreadSynchronizationContext.Update();
             this.TimeInfo.Update();
             this.EntitySystem.Update();
-            SynchronizationContext.SetSynchronizationContext(null);
         }
         
         public void LateUpdate()
         {
-            SynchronizationContext.SetSynchronizationContext(this.ThreadSynchronizationContext);
             this.EntitySystem.LateUpdate();
             FrameFinishUpdate();
-            SynchronizationContext.SetSynchronizationContext(null);
             this.IsRuning = false;
         }
 

+ 5 - 3
Unity/Assets/Scripts/Core/World/Module/Fiber/FiberManager.cs

@@ -26,11 +26,13 @@ namespace ET
             this.mainThreadScheduler = new MainThreadScheduler(this);
             this.schedulers[(int)SchedulerType.Main] = this.mainThreadScheduler;
             
-            //this.schedulers[(int)SchedulerType.Thread] = this.mainThreadScheduler;
-            //this.schedulers[(int)SchedulerType.ThreadPool] = this.mainThreadScheduler;
-            
+#if ENABLE_VIEW && UNITY_EDITOR
+            this.schedulers[(int)SchedulerType.Thread] = this.mainThreadScheduler;
+            this.schedulers[(int)SchedulerType.ThreadPool] = this.mainThreadScheduler;
+#else
             this.schedulers[(int)SchedulerType.Thread] = new ThreadScheduler(this);
             this.schedulers[(int)SchedulerType.ThreadPool] = new ThreadPoolScheduler(this);
+#endif
         }
         
         public void Update()

+ 2 - 0
Unity/Assets/Scripts/Core/World/Module/Fiber/MainThreadScheduler.cs

@@ -44,6 +44,7 @@ namespace ET
 
                 this.idQueue.Enqueue(id);
                 
+                SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
                 fiber.Update();
             }
         }
@@ -71,6 +72,7 @@ namespace ET
 
                 this.idQueue.Enqueue(id);
 
+                SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
                 fiber.LateUpdate();
             }
 

+ 2 - 0
Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadPoolScheduler.cs

@@ -63,8 +63,10 @@ namespace ET
                     // 正在执行的就不执行了
                     if (!fiber.IsRuning)
                     {
+                        SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
                         fiber.Update();
                         fiber.LateUpdate();
+                        SynchronizationContext.SetSynchronizationContext(null);
                     }
 
                     Thread.Sleep(1);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/Login/LoginHelper.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Net;
 using System.Net.Sockets;
+using System.Threading;
 
 namespace ET.Client
 {
@@ -18,7 +19,6 @@ namespace ET.Client
                 {
                     routerAddressComponent = scene.AddComponent<RouterAddressComponent, string, int>(ConstValue.RouterHttpHost, ConstValue.RouterHttpPort);
                     await routerAddressComponent.Init();
-                    
                     scene.AddComponent<NetClientComponent, AddressFamily>(routerAddressComponent.RouterManagerIPAddress.AddressFamily);
                 }
                 IPEndPoint realmAddress = routerAddressComponent.GetRealmAddress(account);

+ 1 - 1
Unity/ProjectSettings/ProjectSettings.asset

@@ -839,7 +839,7 @@ PlayerSettings:
   webGLDecompressionFallback: 0
   webGLPowerPreference: 2
   scriptingDefineSymbols:
-    Android: UNITY;SINGLE_THREAD;ENABLE_DLL
+    Android: UNITY;SINGLE_THREAD;ENABLE_DLL;ENABLE_VIEW
     Server: UNITY
     Standalone: UNITY;SINGLE_THREAD;ENABLE_VIEW;ENABLE_CODES
     WebGL: UNITY;ENABLE_CODES