diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs
index 936d38565..cd774fca6 100644
--- a/Source/Engine/Level/Actor.cs
+++ b/Source/Engine/Level/Actor.cs
@@ -123,6 +123,9 @@ namespace FlaxEngine
/// The child actor.
public Actor AddChild(Type type)
{
+ if (type.IsAbstract)
+ return null;
+
var result = (Actor)New(type);
result.SetParent(this, false, false);
return result;
@@ -135,6 +138,9 @@ namespace FlaxEngine
/// The child actor.
public T AddChild() where T : Actor
{
+ if (typeof(T).IsAbstract)
+ return null;
+
var result = New();
result.SetParent(this, false, false);
return result;
@@ -172,6 +178,9 @@ namespace FlaxEngine
var result = GetChild();
if (result == null)
{
+ if (typeof(T).IsAbstract)
+ return null;
+
result = New();
result.SetParent(this, false, false);
}
@@ -185,6 +194,9 @@ namespace FlaxEngine
/// The created script instance, null otherwise.
public Script AddScript(Type type)
{
+ if (type.IsAbstract)
+ return null;
+
var script = (Script)New(type);
script.Parent = this;
return script;
@@ -197,6 +209,9 @@ namespace FlaxEngine
/// The created script instance, null otherwise.
public T AddScript() where T : Script
{
+ if (typeof(T).IsAbstract)
+ return null;
+
var script = New();
script.Parent = this;
return script;
diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h
index e9ad7793c..e108b0756 100644
--- a/Source/Engine/Level/Actor.h
+++ b/Source/Engine/Level/Actor.h
@@ -227,6 +227,10 @@ public:
T* result = (T*)GetChild(T::GetStaticClass());
if (!result)
{
+ const MClass* type = T::GetStaticClass();
+ if (type->IsAbstract())
+ return nullptr;
+
result = New();
result->SetParent(this, false, false);
}