diff --git a/Source/Engine/Scripting/Runtime/None.cpp b/Source/Engine/Scripting/Runtime/None.cpp
index bb83fd27d..f4cdd92e2 100644
--- a/Source/Engine/Scripting/Runtime/None.cpp
+++ b/Source/Engine/Scripting/Runtime/None.cpp
@@ -253,6 +253,41 @@ MObject* MCore::Exception::GetNotSupported(const char* msg)
return nullptr;
}
+::String MCore::Type::ToString(MType* type)
+{
+ return ::String::Empty;
+}
+
+MClass* MCore::Type::GetClass(MType* type)
+{
+ return nullptr;
+}
+
+MType* MCore::Type::GetElementType(MType* type)
+{
+ return nullptr;
+}
+
+int32 MCore::Type::GetSize(MType* type)
+{
+ return 0;
+}
+
+MTypes MCore::Type::GetType(MType* type)
+{
+ return MTypes::End;
+}
+
+bool MCore::Type::IsPointer(MType* type)
+{
+ return false;
+}
+
+bool MCore::Type::IsReference(MType* type)
+{
+ return false;
+}
+
const MAssembly::ClassesDictionary& MAssembly::GetClasses() const
{
_hasCachedClasses = true;
diff --git a/Source/Engine/Scripting/ScriptingObject.cpp b/Source/Engine/Scripting/ScriptingObject.cpp
index 0eafa2451..0efb817d2 100644
--- a/Source/Engine/Scripting/ScriptingObject.cpp
+++ b/Source/Engine/Scripting/ScriptingObject.cpp
@@ -260,7 +260,11 @@ ScriptingObject* ScriptingObject::ToNative(MObject* obj)
bool ScriptingObject::Is(const ScriptingTypeHandle& type) const
{
CHECK_RETURN(type, false);
+#if SCRIPTING_OBJECT_CAST_WITH_CSHARP
return _type == type || CanCast(GetClass(), type.GetType().ManagedClass);
+#else
+ return CanCast(GetTypeHandle(), type);
+#endif
}
void ScriptingObject::ChangeID(const Guid& newId)
@@ -421,10 +425,16 @@ void ScriptingObject::UnregisterObject()
bool ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
{
+ if (from == to)
+ return true;
if (!from && !to)
return true;
CHECK_RETURN(from && to, false);
+#if SCRIPTING_OBJECT_CAST_WITH_CSHARP
return CanCast(from.GetType().ManagedClass, to.GetType().ManagedClass);
+#else
+ return to.IsAssignableFrom(from);
+#endif
}
bool ScriptingObject::CanCast(const MClass* from, const MClass* to)
diff --git a/Source/Engine/Scripting/ScriptingObject.h b/Source/Engine/Scripting/ScriptingObject.h
index 9de79109f..d893d2700 100644
--- a/Source/Engine/Scripting/ScriptingObject.h
+++ b/Source/Engine/Scripting/ScriptingObject.h
@@ -7,6 +7,8 @@
#include "Engine/Core/Delegate.h"
#include "ManagedCLR/MTypes.h"
+#define SCRIPTING_OBJECT_CAST_WITH_CSHARP (USE_CSHARP)
+
///
/// Represents object from unmanaged memory that can use accessed via scripting.
///
@@ -156,7 +158,11 @@ public:
template
static T* Cast(ScriptingObject* obj)
{
+#if SCRIPTING_OBJECT_CAST_WITH_CSHARP
return obj && CanCast(obj->GetClass(), T::GetStaticClass()) ? static_cast(obj) : nullptr;
+#else
+ return obj && CanCast(obj->GetTypeHandle(), T::TypeInitializer) ? static_cast(obj) : nullptr;
+#endif
}
bool Is(const ScriptingTypeHandle& type) const;
@@ -169,7 +175,11 @@ public:
template
bool Is() const
{
+#if SCRIPTING_OBJECT_CAST_WITH_CSHARP
return CanCast(GetClass(), T::GetStaticClass());
+#else
+ return CanCast(GetTypeHandle(), T::TypeInitializer);
+#endif
}
public: