| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "Wrappers/BsScriptGameObject.h"
- #include "BsMonoUtil.h"
- #include <assert.h>
- namespace bs
- {
- ScriptGameObjectBase::ScriptGameObjectBase(MonoObject* instance)
- :PersistentScriptObjectBase(instance), mGCHandle(0)
- {
-
- }
- ScriptGameObjectBase::~ScriptGameObjectBase()
- {
- BS_ASSERT(mGCHandle == 0 && "Object being destroyed without its managed instance being freed first.");
- }
-
- MonoObject* ScriptGameObjectBase::getManagedInstance() const
- {
- return MonoUtil::getObjectFromGCHandle(mGCHandle);
- }
- void ScriptGameObjectBase::setManagedInstance(::MonoObject* instance)
- {
- BS_ASSERT(mGCHandle == 0 && "Attempting to set a new managed instance without freeing the old one.");
- mGCHandle = MonoUtil::newGCHandle(instance, false);
- }
- void ScriptGameObjectBase::freeManagedInstance()
- {
- if (mGCHandle != 0)
- {
- MonoUtil::freeGCHandle(mGCHandle);
- mGCHandle = 0;
- }
- }
- ScriptGameObject::ScriptGameObject(MonoObject* instance)
- :ScriptObject(instance)
- { }
- void ScriptGameObject::initRuntimeData()
- {
- metaData.scriptClass->addInternalCall("Internal_GetInstanceId", (void*)&ScriptGameObject::internal_getInstanceId);
- }
- UINT64 ScriptGameObject::internal_getInstanceId(ScriptGameObject* nativeInstance)
- {
- return nativeInstance->getNativeHandle().getInstanceId();
- }
- }
|