mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Interactions
This commit is contained in:
parent
e1d6afa512
commit
abff2ea59e
19 changed files with 282 additions and 10 deletions
17
Scripts/Tools.cs
Normal file
17
Scripts/Tools.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts;
|
||||
|
||||
public static class Tools
|
||||
{
|
||||
public static T CreateChild<T>(this Node2D node, PackedScene prefab) where T : Node2D
|
||||
{
|
||||
if (prefab == null) return null;
|
||||
var newInstance = prefab.Instantiate<T>();
|
||||
node.Owner.CallDeferred("add_child", newInstance);
|
||||
newInstance.Transform = node.GlobalTransform;
|
||||
newInstance.Position = node.Position;
|
||||
|
||||
return newInstance;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue