Documentation
¶
Overview ¶
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. Object.SetScript extends an existing object, if that object's class matches one of the script's base classes.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) AsScript() Instance
- func (self Instance) CanInstantiate() bool
- func (self Instance) GetBaseScript() Instance
- func (self Instance) GetGlobalName() string
- func (self Instance) GetInstanceBaseType() string
- func (self Instance) GetPropertyDefaultValue(property string) any
- func (self Instance) GetRpcConfig() any
- func (self Instance) GetScriptConstantMap() map[string]interface{}
- func (self Instance) GetScriptMethodList() []Object.PropertyInfo
- func (self Instance) GetScriptPropertyList() []Object.PropertyInfo
- func (self Instance) GetScriptSignalList() []SignalInfo
- func (self Instance) HasScriptSignal(signal_name string) bool
- func (self Instance) HasSourceCode() bool
- func (self Instance) ID() ID
- func (self Instance) InstanceHas(base_object Object.Instance) bool
- func (self Instance) IsAbstract() bool
- func (self Instance) IsTool() bool
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) Reload() error
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSourceCode(value string)
- func (self Instance) SourceCode() string
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
- type SignalInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) CanInstantiate ¶
Returns true if the script can be instantiated.
func (Instance) GetBaseScript ¶
Returns the script directly inherited by this script.
func (Instance) GetGlobalName ¶
Returns the class name associated with the script, if there is one. Returns an empty string otherwise.
To give the script a global name, you can use the class_name keyword in GDScript and the [GlobalClass] attribute in C#.
package main
func (Instance) GetInstanceBaseType ¶
Returns the script's base type.
func (Instance) GetPropertyDefaultValue ¶
Returns the default value of the specified property.
func (Instance) GetRpcConfig ¶
Returns a data structure mapping method names to their RPC configuration defined by this script.
func (Instance) GetScriptConstantMap ¶
Returns a dictionary containing constant names and their values.
func (Instance) GetScriptMethodList ¶
func (self Instance) GetScriptMethodList() []Object.PropertyInfo
Returns the list of methods in this Script.
Note: The dictionaries returned by this method are formatted identically to those returned by Object.GetMethodList.
func (Instance) GetScriptPropertyList ¶
func (self Instance) GetScriptPropertyList() []Object.PropertyInfo
Returns the list of properties in this Script.
Note: The dictionaries returned by this method are formatted identically to those returned by Object.GetPropertyList.
func (Instance) GetScriptSignalList ¶
func (self Instance) GetScriptSignalList() []SignalInfo
Returns the list of user signals defined in this Script.
Note: The dictionaries returned by this method are formatted identically to those returned by Object.GetSignalList.
func (Instance) HasScriptSignal ¶
Returns true if the script, or a base class, defines a signal with the given name.
func (Instance) HasSourceCode ¶
Returns true if the script contains non-empty source code.
Note: If a script does not have source code, this does not mean that it is invalid or unusable. For example, a GDScript that was exported with binary tokenization has no source code, but still behaves as expected and could be instantiated. This can be checked with CanInstantiate.
func (Instance) InstanceHas ¶
Returns true if 'base_object' is an instance of this script.
func (Instance) IsAbstract ¶
Returns true if the script is an abstract script. An abstract script does not have a constructor and cannot be instantiated.
func (Instance) IsTool ¶
Returns true if the script is a tool script. A tool script can run in the editor.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) SetSourceCode ¶
SetSourceCode sets the property returned by [GetSourceCode].
func (Instance) SourceCode ¶
The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.
type MoreArgs ¶
MoreArgs is a container for Instance functions with additional 'optional' arguments.
type SignalInfo ¶
type SignalInfo struct { Name string `gd:"name"` Flags int `gd:"flags"` ID int `gd:"id"` DefaultArgs []interface{} `gd:"default_args"` Args []Object.PropertyInfo `gd:"args"` }