summaryrefslogtreecommitdiff
path: root/Runtime/BaseClasses/RefCounted.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/BaseClasses/RefCounted.h
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/BaseClasses/RefCounted.h')
-rw-r--r--Runtime/BaseClasses/RefCounted.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/Runtime/BaseClasses/RefCounted.h b/Runtime/BaseClasses/RefCounted.h
new file mode 100644
index 0000000..cbe2934
--- /dev/null
+++ b/Runtime/BaseClasses/RefCounted.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "Configuration/UnityConfigure.h"
+#include "Runtime/Mono/MonoIncludes.h"
+#include "Runtime/Scripting/ScriptingUtility.h"
+#include "Runtime/Scripting/Backend/ScriptingBackendApi.h"
+
+class TrackedReferenceBase
+{
+public:
+ int m_MonoObjectReference;
+
+ TrackedReferenceBase ()
+ {
+ m_MonoObjectReference = 0;
+ }
+
+ ~TrackedReferenceBase ()
+ {
+#if ENABLE_SCRIPTING
+ if (m_MonoObjectReference)
+ {
+ ScriptingObjectPtr target = scripting_gchandle_get_target (m_MonoObjectReference);
+ if (target)
+ {
+ void* nativePointer = 0;
+ MarshallNativeStructIntoManaged(nativePointer,target);
+ target = SCRIPTING_NULL;
+ }
+
+ scripting_gchandle_free (m_MonoObjectReference);
+ m_MonoObjectReference = 0;
+ }
+#endif
+ }
+};