summaryrefslogtreecommitdiff
path: root/Runtime/IMGUI/GUIContent.cpp
blob: 6b811c7362cadd47f0df7a09fc3a03af35f2152c (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
#include "UnityPrefix.h"
#include "Runtime/IMGUI/GUIContent.h"
#include "Runtime/Scripting/ScriptingUtility.h"

#if ENABLE_SCRIPTING
static GUIContent s_TempGUIContent;
#if UNITY_WINRT
void MonoGUIContentToTempNativeCallback(Platform::String^ text, Platform::String^ tooltip, long long image)
{
	s_TempGUIContent.m_Text.BorrowString (text);
	s_TempGUIContent.m_Tooltip.BorrowString (tooltip);
	s_TempGUIContent.m_Image = ScriptingObjectToObject<Texture> (ScriptingObjectPtr(image));
}
BridgeInterface::ScriptingGUIContentToTempNativeDelegateGC^ GetMonoGUIContentToTempNativeCallback()
{
	static BridgeInterface::ScriptingGUIContentToTempNativeDelegateGC^ s_Callback  = ref new BridgeInterface::ScriptingGUIContentToTempNativeDelegateGC(MonoGUIContentToTempNativeCallback);
	return s_Callback;
}

#endif

GUIContent &MonoGUIContentToTempNative (ScriptingObjectPtr scriptingContent)
{
	MonoGUIContentToNative (scriptingContent, s_TempGUIContent);
	return s_TempGUIContent;
}

void MonoGUIContentToNative (ScriptingObjectPtr scriptingContent, GUIContent& cppContent)
{
	if (scriptingContent == SCRIPTING_NULL)
	{
		WarningString("GUIContent is null. Use GUIContent.none.");
		cppContent.m_Text = (UTF16String) "";
		cppContent.m_Tooltip = (UTF16String)  "";
		cppContent.m_Image = NULL;

		return;
	}

#if UNITY_WINRT
	GetWinRTUtils()->ScriptingGUIContentToTempNativeGC(scriptingContent.GetHandle(), GetMonoGUIContentToTempNativeCallback());
#else
	MonoGUIContent nativeContent;
 	MarshallManagedStructIntoNative(scriptingContent, &nativeContent);
	
#	if ENABLE_MONO 
		cppContent.m_Text.BorrowString (nativeContent.m_Text);
		cppContent.m_Tooltip.BorrowString (nativeContent.m_Tooltip);
#	elif UNITY_FLASH
		Ext_WriteTextAndToolTipIntoUTF16Strings(scriptingContent,&cppContent.m_Text,&cppContent.m_Tooltip);
#	endif	

	cppContent.m_Image = ScriptingObjectToObject<Texture> (nativeContent.m_Image);
#endif
	return;
}

#endif