Documentation
¶
Overview ¶
Package Object provides methods for working with Object instances.
Index ¶
- func As[T gd.IsClass](value gd.IsClass) T
- func Is[T gd.IsClass](value gd.IsClass) (T, bool)
- func Use(obj interface{ ... })
- type Advanced
- type ID
- type Instance
- func (obj Instance) AsObject() [1]gd.Object
- func (obj Instance) CanTranslateMessages() bool
- func (obj Instance) ClassName() string
- func (obj Instance) ID() ID
- func (obj Instance) NotifyPropertyListChanged()
- func (obj Instance) Script() ([1]gdclass.Script, bool)
- func (obj Instance) SetMessageTranslation(enable bool)
- func (obj Instance) SetScript(script [1]gdclass.Script)
- func (obj Instance) SetSignalsBlocked(enable bool)
- func (obj Instance) SignalsBlocked() bool
- func (obj Instance) String() string
- func (obj Instance) Translate(message string) string
- func (obj Instance) Translation(message string, plural_message string, n int, context string) string
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (obj Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As attempts to cast the given class to T, returning the casted value if successful, or panicking if not.
Types ¶
type Advanced ¶
func (*Advanced) UnsafePointer ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID uniquely and opaquely identifies an Object instance.
type Instance ¶
Instance is an advanced Variant type. All classes in the engine inherit from Object. Each class may define new properties, methods or signals, which are available to all inheriting classes. For example, a Sprite2D instance is able to call Node.add_child because it inherits from Node.
You can create new instances, using New.
Objects can have a Script attached to them. Once the Script is instantiated, it effectively acts as an extension to the base class, allowing it to define and inherit new properties, methods and signals.
func (Instance) CanTranslateMessages ¶
CanTranslateMessages returns true if the object is allowed to translate messages with tr and tr_n. See also Instance.SetMessageTranslation.
func (Instance) ID ¶
ID returns the object's unique instance ID. This ID can be saved in EncodedObjectAsID, and can be used to retrieve this object instance with ID.Instance.
func (Instance) NotifyPropertyListChanged ¶
func (obj Instance) NotifyPropertyListChanged()
NotifyPropertyListChanged emits the property_list_changed signal. This is mainly used to refresh the editor, so that the Inspector and editor plugins are properly updated.
func (Instance) Script ¶
ScriptInstance returns the object's Script instance, or false if no script is attached.
func (Instance) SetMessageTranslation ¶
SetMessageTranslation if set to true, allows the object to translate messages with tr and tr_n. Enabled by default. See also Instance.CanTranslateMessages.
func (Instance) SetScript ¶
SetScript attaches script to the object, and instantiates it. As a result, the script's _init is called. A Script is used to extend the object's functionality.
If a script already exists, its instance is detached, and its property values and state are lost. Built-in property values are still kept.
func (Instance) SetSignalsBlocked ¶
SetBlockSignals if set to true, the object becomes unable to emit signals. Signal connections will not work, until it is set to false.
func (Instance) SignalsBlocked ¶
SignalsBlocked returns true if the object is blocking its signals from being emitted. See Instance.SetSignalsBlocked.
func (Instance) String ¶
String returns a String representing the object. Defaults to "<ClassName#RID>". Override _to_string to customize the string representation of the object.
func (Instance) Translate ¶
Translate translates a message, using the translation catalogs configured in the Project Settings. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
If Instance.CanTranslateMessages is false, or no translation is available, this method returns the message without changes. See Instance.SetMessageTranslation.
func (Instance) Translation ¶
func (obj Instance) Translation(message string, plural_message string, n int, context string) string
Translation translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.
If Instance.CanTranslateMessages is false, or no translation is available, this method returns message or plural_message, without changes. See Instance.SetMessageTranslation.
The n is the number, or amount, of the message's subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and float numbers may not properly apply to some countable subjects. It's recommended to handle these cases with Instance.Translate.
Note: This method can't be used without an Object instance, as it requires the Instance.CanTranslateMessages method. To translate strings in a static context, use [TranslationServer.TranslatePlural].