Skip to content

Commit a3e432f

Browse files
Handle Unity debug output writing specifically
The ENABLE_MONO preproc is not the ideal test for being in unity... but UNITY doesn't work, and UnityEngine is undefined when compiling FOR unity (and the FOR_UNITY preproc is defined by the .csproj file)
1 parent f0e6b09 commit a3e432f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

ROS_Comm/_Init.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private static void _writeline(object o)
5959
{
6060
if (OtherOutput != null)
6161
OtherOutput(o);
62+
#if !ENABLE_MONO
6263
bool toDebugInstead =
6364
#if FOR_UNITY
6465
true;
@@ -72,11 +73,14 @@ private static void _writeline(object o)
7273
{
7374
toDebugInstead = true;
7475
}
75-
#endif
76+
#endif //FOR_UNITY
7677
if (toDebugInstead)
7778
Debug.WriteLine(o);
7879
else
7980
Console.WriteLine(o);
81+
#else
82+
UnityEngine.Debug.LogWarning(o.ToString());
83+
#endif //!UNITY
8084
}
8185

8286
/// Writes a string or something to System.Console, and fires an optional OtherOutput event for use in the node

XmlRpc_Wrapper/XmlRpcUtil.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ public static void SetLogLevel(int level)
309309

310310
public static void error(string format, params object[] list)
311311
{
312+
#if ENABLE_MONO
313+
UnityEngine.Debug.LogError(String.Format(format, list));
314+
#else
312315
Debug.WriteLine(String.Format(format, list));
316+
#endif
313317
}
314318

315319
public static void log(int level, string format, params object[] list)
@@ -320,7 +324,11 @@ public static void log(int level, string format, params object[] list)
320324
public static void log(XMLRPC_LOG_LEVEL level, string format, params object[] list)
321325
{
322326
if (level <= MINIMUM_LOG_LEVEL)
327+
#if ENABLE_MONO
328+
UnityEngine.Debug.LogWarning(String.Format(format, list));
329+
#else
323330
Debug.WriteLine(String.Format(format, list));
331+
#endif
324332
}
325333
}
326334
}

XmlRpc_Wrapper/XmlRpc_Wrapper_UNITY.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
3838
<DebugSymbols>true</DebugSymbols>
3939
<OutputPath>bin\Debug\</OutputPath>
40-
<DefineConstants>
41-
</DefineConstants>
40+
<DefineConstants>FOR_UNITY</DefineConstants>
4241
<Optimize>false</Optimize>
4342
<DebugType>full</DebugType>
4443
<PlatformTarget>AnyCPU</PlatformTarget>

0 commit comments

Comments
 (0)