Explorar o código

ET的Log支持编辑器逻辑里面使用 (#439)

* ET的Log支持编辑器逻辑里面使用

以前在编辑器逻辑里面使用ET的Log时会Logger.Instance报null
肖红 %!s(int64=3) %!d(string=hai) anos
pai
achega
a998103c5f
Modificáronse 1 ficheiros con 61 adicións e 5 borrados
  1. 61 5
      Unity/Assets/Scripts/Core/Module/Log/Log.cs

+ 61 - 5
Unity/Assets/Scripts/Core/Module/Log/Log.cs

@@ -6,42 +6,98 @@ namespace ET
     {
         public static void Trace(string msg)
         {
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.Log(msg);
+                return;
+            }
+#endif
             Logger.Instance.Trace(msg);
         }
 
         public static void Debug(string msg)
         {
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.Log(msg);
+                return;
+            }
+#endif
             Logger.Instance.Debug(msg);
         }
 
         public static void Info(string msg)
         {
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.Log(msg);
+                return;
+            }
+#endif
             Logger.Instance.Info(msg);
         }
 
         public static void TraceInfo(string msg)
         {
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.Log(msg);
+                return;
+            }
+#endif
             Logger.Instance.Trace(msg);
         }
 
         public static void Warning(string msg)
         {
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.LogWarning(msg);
+                return;
+            }
+#endif
             Logger.Instance.Warning(msg);
         }
 
         public static void Error(string msg)
         {
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.LogError(msg);
+                return;
+            }
+#endif      
             Logger.Instance.Error(msg);
         }
 
-        public static void Error(Exception e)
+        public static void Error(Exception msg)
         {
-            Logger.Instance.Error(e);
+#if UNITY     
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.LogError(msg);
+                return;
+            }
+ #endif          
+            Logger.Instance.Error(msg);
         }
 
-        public static void Console(string message)
+        public static void Console(string msg)
         {
-            Logger.Instance.Console(message);
+#if UNITY
+            if (!UnityEngine.Application.isPlaying)
+            {
+                UnityEngine.Debug.Log(msg);
+                return;
+            }
+#endif  
+            Logger.Instance.Console(msg);
         }
         
 #if DOTNET
@@ -76,4 +132,4 @@ namespace ET
         }
 #endif
     }
-}
+}