File tree 2 files changed +28
-6
lines changed
2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 6
6
7
7
namespace KBEngine
8
8
{
9
+ public enum DEBUGLEVEL : int
10
+ {
11
+ DEBUG = 0 ,
12
+ INFO ,
13
+ WARNING ,
14
+ ERROR ,
15
+
16
+ NOLOG , // 放在最后面,使用这个时表示不输出任何日志(!!!慎用!!!)
17
+ }
18
+
9
19
public class Dbg
10
20
{
21
+ static public DEBUGLEVEL debugLevel = DEBUGLEVEL . DEBUG ;
22
+
11
23
#if UNITY_EDITOR
12
24
static Dictionary < string , Profile > _profiles = new Dictionary < string , Profile > ( ) ;
13
25
#endif
@@ -19,22 +31,26 @@ public static string getHead()
19
31
20
32
public static void INFO_MSG ( object s )
21
33
{
22
- Debug . Log ( getHead ( ) + s ) ;
34
+ if ( DEBUGLEVEL . INFO >= debugLevel )
35
+ Debug . Log ( getHead ( ) + s ) ;
23
36
}
24
37
25
38
public static void DEBUG_MSG ( object s )
26
39
{
27
- Debug . Log ( getHead ( ) + s ) ;
40
+ if ( DEBUGLEVEL . DEBUG >= debugLevel )
41
+ Debug . Log ( getHead ( ) + s ) ;
28
42
}
29
43
30
44
public static void WARNING_MSG ( object s )
31
45
{
32
- Debug . LogWarning ( getHead ( ) + s ) ;
46
+ if ( DEBUGLEVEL . WARNING >= debugLevel )
47
+ Debug . LogWarning ( getHead ( ) + s ) ;
33
48
}
34
49
35
50
public static void ERROR_MSG ( object s )
36
51
{
37
- Debug . LogError ( getHead ( ) + s ) ;
52
+ if ( DEBUGLEVEL . ERROR >= debugLevel )
53
+ Debug . LogError ( getHead ( ) + s ) ;
38
54
}
39
55
40
56
public static void profileStart ( string name )
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public class KBEMain : MonoBehaviour
13
13
public KBEngineApp gameapp = null ;
14
14
15
15
// 在unity3d界面中可见选项
16
+ public DEBUGLEVEL debugLevel = DEBUGLEVEL . DEBUG ;
16
17
public bool isMultiThreads = true ;
17
18
public string ip = "127.0.0.1" ;
18
19
public int port = 20013 ;
@@ -43,7 +44,9 @@ public virtual void installEvents()
43
44
public virtual void initKBEngine ( )
44
45
{
45
46
// 如果此处发生错误,请查看 Assets\Scripts\kbe_scripts\if_Entity_error_use______git_submodule_update_____kbengine_plugins_______open_this_file_and_I_will_tell_you.cs
46
-
47
+
48
+ Dbg . debugLevel = debugLevel ;
49
+
47
50
KBEngineArgs args = new KBEngineArgs ( ) ;
48
51
49
52
args . ip = ip ;
@@ -72,7 +75,10 @@ public virtual void initKBEngine()
72
75
void OnDestroy ( )
73
76
{
74
77
MonoBehaviour . print ( "clientapp::OnDestroy(): begin" ) ;
75
- KBEngineApp . app . destroy ( ) ;
78
+ if ( KBEngineApp . app != null )
79
+ {
80
+ KBEngineApp . app . destroy ( ) ;
81
+ }
76
82
MonoBehaviour . print ( "clientapp::OnDestroy(): end" ) ;
77
83
}
78
84
You can’t perform that action at this time.
0 commit comments