This commit is contained in:
Liam 2021-11-10 13:34:33 -05:00 committed by GitHub
commit 14d4686477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -73,6 +73,17 @@ namespace Godot
_delegate = @delegate;
}
/// <summary>
/// Constructs a new <see cref="Callable"/> for the given <paramref name="callback"/>.
/// </summary>
/// <param name="callback">Action method that will be called.</param>
public Callable(Action callback)
{
_target = null;
_method = null;
_delegate = callback;
}
/// <summary>
/// Calls the method represented by this <see cref="Callable"/>.
/// Arguments can be passed and should match the method's signature.

View file

@ -132,6 +132,22 @@ namespace Godot
return new SignalAwaiter(source, signal, this);
}
/// <summary>
/// Calls the specified <see cref="Action"/> during idle time. Example:
/// <code>
/// public override void _Process(float delta)
/// {
/// var collisionShape = GetNode&lt;CollisionShape2D&gt;("CollisionShape2D");
/// Defer(() => collisionShape.Disabled = true);
/// }
/// </code>
/// </summary>
/// <param name="callback">Callback to call during idle time.</param>
protected void Defer(Action callback)
{
new Callable(callback).CallDeferred();
}
/// <summary>
/// Gets a new <see cref="DynamicGodotObject"/> associated with this instance.
/// </summary>