summaryrefslogtreecommitdiff
path: root/Runtime/Export/UnityEngineDebug.txt
blob: 28c983202681c769351afd6bb11d207ef26a0376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
C++RAW


#include "UnityPrefix.h"
#include "Configuration/UnityConfigure.h"
#include "Runtime/Input/InputManager.h"
#include "Runtime/Input/TimeManager.h"
#include "Runtime/Misc/DeveloperConsole.h"
#include "Runtime/Misc/ResourceManager.h"
#include "Runtime/Mono/MonoBehaviour.h"
#include "Runtime/Misc/DebugUtility.h"
#include "Runtime/Misc/BuildSettings.h"
#include "Runtime/Misc/DeveloperConsole.h"
#include "Runtime/Scripting/ScriptingUtility.h"

#if UNITY_EDITOR
	#include "Editor/Src/EditorSettings.h"
	#include "Editor/Src/EditorUserBuildSettings.h"
	#include "Editor/Mono/MonoEditorUtility.h"
	#include "Editor/Src/AssetPipeline/MonoCompilationPipeline.h"
#endif
	
using namespace Unity;

using namespace std;

CSRAW
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Collections;

namespace UnityEngine
{

// Class containing methods to ease debugging while developing a game.
CLASS Debug

	// Draws a line from the /point/ start to /end/ with color for a duration of time and with or without depth testing. If duration is 0 then the line is rendered 1 frame.

	CUSTOM public static void DrawLine (Vector3 start, Vector3 end, Color color = Color.white, float duration = 0.0f, bool depthTest = true) { DebugDrawLine (start, end, color, duration, depthTest); }

	
	// Draws a line from /start/ to /start/ + /dir/ with color for a duration of time and with or without depth testing. If duration is 0 then the line is rendered 1 frame.
	
	CSRAW public static void DrawRay (Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true) { DrawLine (start, start + dir, color, duration, depthTest); }
	
	
	// Pauses the editor.
	CUSTOM static void Break () { PauseEditor (); }

	// Breaks into the attached debugger, if present
	CUSTOM static void DebugBreak ()
	{ 
		#if DEBUGMODE && (UNITY_WIN && !UNITY_WINRT)
		if( IsDebuggerPresent() )
			::DebugBreak();
		#endif
	}		
	
	THREAD_SAFE
	CUSTOM private static void Internal_Log (int level, string msg, [Writable]Object obj)
	{
		DebugStringToFile (msg.AsUTF8().c_str(), 0, __FILE__, __LINE__, (level==0?kScriptingLog:level==1?kScriptingWarning:kScriptingError) | kMayIgnoreLineNumber, obj.GetInstanceID());
	}

	THREAD_SAFE
	CUSTOM private static void Internal_LogException(Exception exception, [Writable]Object obj)
	{
		Scripting::LogException(exception, obj.GetInstanceID());
	}

	// Logs /message/ to the Unity Console.
	CSRAW public static void Log (object message) { Internal_Log (0, message != null ? message.ToString () : "Null", null); }

	// Logs /message/ to the Unity Console.
	CSRAW public static void Log (object message, Object context) 
	{ 
		Internal_Log (0, message != null ? message.ToString () : "Null", context); 
	}
	
	// A variant of Debug.Log that logs an error message to the console.
	CSRAW public static void LogError (object message) { Internal_Log (2, message != null ? message.ToString () : "Null", null); }

	// A variant of Debug.Log that logs an error message to the console.
	CSRAW public static void LogError (object message, Object context) { Internal_Log (2,message.ToString (), context); }

	// Clears errors from the developer console.
	CUSTOM public static void ClearDeveloperConsole () 
	{ 
	#if UNITY_HAS_DEVELOPER_CONSOLE
		if (GetDeveloperConsolePtr() != NULL) GetDeveloperConsolePtr()->Clear(); 
	#endif
	}

	// Opens or closes developer console.
	CUSTOM_PROP static bool developerConsoleVisible
	{ 
	#if UNITY_HAS_DEVELOPER_CONSOLE
		if (GetDeveloperConsolePtr() != NULL) return GetDeveloperConsolePtr()->IsVisible();
	#endif
		return false;
	}
	{
	#if UNITY_HAS_DEVELOPER_CONSOLE
		if (GetDeveloperConsolePtr() != NULL) return GetDeveloperConsolePtr()->SetOpen(value);
	#endif
	}

	// A variant of Debug.Log that logs an error message from an exception to the console.
	CSRAW public static void LogException(Exception exception) { Internal_LogException(exception, null); }

	// A variant of Debug.Log that logs an error message to the console.
	CSRAW public static void LogException(Exception exception, Object context) { Internal_LogException(exception, context); }

	CONDITIONAL UNITY_EDITOR
	CUSTOM internal static void LogPlayerBuildError (string message,string file,int line, int column)
	{ 
		DebugStringToFilePostprocessedStacktrace (message.AsUTF8().c_str(), "", "", 1, file.AsUTF8().c_str(), line, kScriptingError | kDontExtractStacktrace, 0, GetBuildErrorIdentifier());
	}
	
	// A variant of Debug.Log that logs a warning message to the console.
	CSRAW public static void LogWarning (object message) { Internal_Log (1,message.ToString (), null); }

	// A variant of Debug.Log that logs a warning message to the console.
	CSRAW public static void LogWarning (object message, Object context) { Internal_Log (1,message.ToString (), context); }
	
	// In the Build Settings dialog there is a check box called "Development Build".
	CUSTOM_PROP static bool isDebugBuild { return GetBuildSettings().isDebugBuild; }
		
	CUSTOM internal static void OpenConsoleFile() { DeveloperConsole_OpenConsoleFile(); }
END

CSRAW }