Click or drag to resize

DynamicGodotObject Class

Represents an Object whose members can be dynamically accessed at runtime through the Variant API.
Inheritance Hierarchy
System.DynamicDynamicObject
  GodotDynamicGodotObject

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public class DynamicGodotObject : DynamicObject

The DynamicGodotObject type exposes the following members.

Constructors
  NameDescription
Public methodDynamicGodotObject
Initializes a new instance of the DynamicGodotObject class.
Top
Properties
  NameDescription
Public propertyValue
Gets the Object associated with this DynamicGodotObject.
Top
Methods
Remarks

The DynamicGodotObject class enables access to the Variant members of a Object instance at runtime.

This allows accessing the class members using their original names in the engine as well as the members from the script attached to the Object, regardless of the scripting language it was written in.

Examples
This sample shows how to use DynamicGodotObject to dynamically access the engine members of a Object.
dynamic sprite = GetNode("Sprite").DynamicGodotObject;
sprite.add_child(this);

if ((sprite.hframes * sprite.vframes) > 0)
    sprite.frame = 0;
Examples
This sample shows how to use DynamicGodotObject to dynamically access the members of the script attached to a Object.
dynamic childNode = GetNode("ChildNode").DynamicGodotObject;

if (childNode.print_allowed)
{
    childNode.message = "Hello from C#";
    childNode.print_message(3);
}
The ChildNode node has the following GDScript script attached:
// # ChildNode.gd
// var print_allowed = true
// var message = ""
// 
// func print_message(times):
//     for i in times:
//         print(message)
See Also