Skip to content

Commit

Permalink
CreateGameObjectWithComp<T> added, shorthand for Scene.CreateGameObje…
Browse files Browse the repository at this point in the history
…ct().AddComponent()
  • Loading branch information
ThatGuy-GEWP committed Aug 2, 2024
1 parent 8bc1974 commit 8af459e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions SFMLGE Local deps/Engine/System/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ public GameObject CreateGameObject(string name = "", GameObject? parent = null)
return go;
}

/// <summary>
/// Creates a new <see cref="GameObject"/> and attaches a component to it.<para></para>
/// Shorthand for <c>Scene.CreateGameObject().AddComponent</c>
/// </summary>
/// <typeparam name="T">The component type.</typeparam>
/// <param name="comp">The component instance to add</param>
/// <param name="name">The new GameObject's name</param>
/// <param name="parent">The new Parent of the GameObject</param>
/// <returns>A Component instance attached to a newly created GameObject</returns>
public T CreateGameObjectWithComp<T>(T comp, string name = "", GameObject? parent = null) where T : Component
{
return CreateGameObject(name, parent).AddComponent(comp);
}

string GetValidName(string fromName)
{
if (usedNames.Contains(fromName))
Expand Down

0 comments on commit 8af459e

Please sign in to comment.