Browse Source

Convenience method Context::CreateObject<T>() for creating objects akin to Node::CreateComponent<T>(...)

bit 9 years ago
parent
commit
d503a84e81
1 changed files with 5 additions and 0 deletions
  1. 5 0
      Source/Urho3D/Core/Context.h

+ 5 - 0
Source/Urho3D/Core/Context.h

@@ -40,6 +40,11 @@ public:
     /// Destruct.
     ~Context();
 
+    /// Create an object by type. Return pointer to it or null if no factory found.
+    template <class T> inline SharedPtr<T> CreateObject()
+    {
+        return StaticCast<T>(CreateObject(T::GetTypeStatic()));
+    }
     /// Create an object by type hash. Return pointer to it or null if no factory found.
     SharedPtr<Object> CreateObject(StringHash objectType);
     /// Register a factory for an object type.