Script
A class stored as a resource.
Script.swift:22class Script
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(_:)
extends an existing object, if that object’s class matches one of the script’s base classes.
Superclasses
class Resource
Base class for serializable objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var sourceCode: String
The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.
func canInstantiate(
) -> Bool Returns
true
if the script can be instantiated.func getBaseScript(
) -> Script? Returns the script directly inherited by this script.
func getGlobalName(
) -> StringName Returns the class name associated with the script, if there is one. Returns an empty string otherwise.
func getInstanceBaseType(
) -> StringName Returns the script’s base type.
func getPropertyDefaultValue(property: StringName
) -> Variant Returns the default value of the specified property.
func getScriptConstantMap(
) -> GDictionary Returns a dictionary containing constant names and their values.
func getScriptMethodList(
) -> VariantCollection<GDictionary> Returns the list of methods in this
Script
.func getScriptPropertyList(
) -> VariantCollection<GDictionary> Returns the list of properties in this
Script
.func getScriptSignalList(
) -> VariantCollection<GDictionary> Returns the list of user signals defined in this
Script
.func hasScriptSignal(signalName: StringName
) -> Bool Returns
true
if the script, or a base class, defines a signal with the given name.func hasSourceCode(
) -> Bool Returns
true
if the script contains non-empty source code.func instanceHas(baseObject: Object?
) -> Bool Returns
true
ifbaseObject
is an instance of this script.func isAbstract(
) -> Bool Returns
true
if the script is an abstract script. An abstract script does not have a constructor and cannot be instantiated.func isTool(
) -> Bool Returns
true
if the script is a tool script. A tool script can run in the editor.func reload(keepState: Bool
) -> GodotError Reloads the script’s class implementation. Returns an error code.
Subclasses
class GDScript
A script implemented in the GDScript programming language.
class ScriptExtension