Class Script
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A class stored as a resource. A script extends the functionality of all objects that instantiate it.
This is the base class for all scripts and should not be used directly. Trying to create a new script with this class will result in an error.
The new
method of a script subclass creates a new instance. SetScript(Variant) extends an existing object, if that object's class matches one of the script's base classes.
public class Script : Resource, IDisposable
- Inheritance
-
Script
- Implements
- Derived
- Inherited Members
Properties
SourceCode
The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.
public string SourceCode { get; set; }
Property Value
Methods
CanInstantiate()
Returns true
if the script can be instantiated.
public bool CanInstantiate()
Returns
GetBaseScript()
Returns the script directly inherited by this script.
public Script GetBaseScript()
Returns
GetInstanceBaseType()
Returns the script's base type.
public StringName GetInstanceBaseType()
Returns
GetPropertyDefaultValue(StringName)
Returns the default value of the specified property.
public Variant GetPropertyDefaultValue(StringName property)
Parameters
property
StringName
Returns
GetScriptConstantMap()
Returns a dictionary containing constant names and their values.
public Dictionary GetScriptConstantMap()
Returns
GetScriptMethodList()
Returns the list of methods in this Script.
public Array<Dictionary> GetScriptMethodList()
Returns
GetScriptPropertyList()
Returns the list of properties in this Script.
public Array<Dictionary> GetScriptPropertyList()
Returns
GetScriptSignalList()
Returns the list of user signals defined in this Script.
public Array<Dictionary> GetScriptSignalList()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
HasScriptSignal(StringName)
Returns true
if the script, or a base class, defines a signal with the given name.
public bool HasScriptSignal(StringName signalName)
Parameters
signalName
StringName
Returns
HasSourceCode()
Returns true
if the script contains non-empty source code.
public bool HasSourceCode()
Returns
InstanceHas(GodotObject)
Returns true
if baseObject
is an instance of this script.
public bool InstanceHas(GodotObject baseObject)
Parameters
baseObject
GodotObject
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsAbstract()
Returns true
if the script is an abstract script. An abstract script does not have a constructor and cannot be instantiated.
public bool IsAbstract()
Returns
IsTool()
Returns true
if the script is a tool script. A tool script can run in the editor.
public bool IsTool()
Returns
Reload(bool)
Reloads the script's class implementation. Returns an error code.
public Error Reload(bool keepState = false)
Parameters
keepState
bool