Trait IVisualShaderNodeCustom
pub trait IVisualShaderNodeCustom: GodotClass<Base = VisualShaderNodeCustom> + You_forgot_the_attribute__godot_api {
Show 33 methods
// Provided methods
fn init(base: Base<Self::Base>) -> Self { ... }
fn on_notification(&mut self, what: ObjectNotification) { ... }
fn on_get(&self, property: StringName) -> Option<Variant> { ... }
fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... }
fn on_validate_property(&self, property: &mut PropertyInfo) { ... }
fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... }
fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... }
fn to_string(&self) -> GString { ... }
fn get_name(&self) -> GString { ... }
fn get_description(&self) -> GString { ... }
fn get_category(&self) -> GString { ... }
fn get_return_icon_type(&self) -> PortType { ... }
fn get_input_port_count(&self) -> i32 { ... }
fn get_input_port_type(&self, port: i32) -> PortType { ... }
fn get_input_port_name(&self, port: i32) -> GString { ... }
fn get_input_port_default_value(&self, port: i32) -> Variant { ... }
fn get_default_input_port(&self, type_: PortType) -> i32 { ... }
fn get_output_port_count(&self) -> i32 { ... }
fn get_output_port_type(&self, port: i32) -> PortType { ... }
fn get_output_port_name(&self, port: i32) -> GString { ... }
fn get_property_count(&self) -> i32 { ... }
fn get_property_name(&self, index: i32) -> GString { ... }
fn get_property_default_index(&self, index: i32) -> i32 { ... }
fn get_property_options(&self, index: i32) -> PackedArray<GString> { ... }
fn get_code(
&self,
input_vars: Array<GString>,
output_vars: Array<GString>,
mode: Mode,
type_: Type,
) -> GString { ... }
fn get_func_code(&self, mode: Mode, type_: Type) -> GString { ... }
fn get_global_code(&self, mode: Mode) -> GString { ... }
fn is_highend(&self) -> bool { ... }
fn is_available(&self, mode: Mode, type_: Type) -> bool { ... }
fn setup_local_to_scene(&mut self) { ... }
fn get_rid(&self) -> Rid { ... }
fn reset_state(&mut self) { ... }
fn set_path_cache(&self, path: GString) { ... }
}Expand description
§Interface trait for class VisualShaderNodeCustom.
Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.
§Related symbols
Base interfaces: > IVisualShaderNodeIResource > IRefCounted > IObject.
(Strike-through means some intermediate Godot classes are marked final, and can thus not be inherited by GDExtension.)
Provided Methods§
fn init(base: Base<Self::Base>) -> Self
fn init(base: Base<Self::Base>) -> Self
Godot constructor, accepting an injected base object.
base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded.
This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.
If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.
fn on_notification(&mut self, what: ObjectNotification)
fn on_notification(&mut self, what: ObjectNotification)
Called when the object receives a Godot notification.
The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_*
constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists
to represent integers out of known constants (mistakes or future additions).
This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the
Object::notify method.
See also in Godot docs:
fn on_get(&self, property: StringName) -> Option<Variant>
fn on_get(&self, property: StringName) -> Option<Variant>
Called whenever get() is called or Godot gets the value of a property.
Should return the given property’s value as Some(value), or None if the property should be handled normally.
See also in Godot docs:
fn on_set(&mut self, property: StringName, value: Variant) -> bool
fn on_set(&mut self, property: StringName, value: Variant) -> bool
Called whenever Godot set() is called or Godot sets the value of a property.
Should set property to the given value and return true, or return false to indicate the property
should be handled normally.
See also in Godot docs:
fn on_validate_property(&self, property: &mut PropertyInfo)
fn on_validate_property(&self, property: &mut PropertyInfo)
Called whenever Godot retrieves value of property. Allows to customize existing properties.
Every property info goes through this method, except properties added with on_get_property_list().
Exposed property here is a shared mutable reference obtained (and returned to) from Godot.
See also in the Godot docs:
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
Available on since_api=4.3 only.
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
since_api=4.3 only.Called whenever Godot get_property_list() is called, the returned vector here is
appended to the existing list of properties.
This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.
See also in Godot docs:
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
Called by Godot to tell if a property has a custom revert or not.
Return None for no custom revert, and return Some(value) to specify the custom revert.
This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this
function will usually be called twice by Godot to find the revert.
Note that this should be a pure function. That is, it should always return the same value for a property as long as self
remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.
fn to_string(&self) -> GString
fn to_string(&self) -> GString
String representation of the Godot instance.
Override this method to define how the instance is represented as a string.
Used by impl Display for Gd<T>, as well as str() and print() in GDScript.
fn get_name(&self) -> GString
fn get_name(&self) -> GString
Override this method to define the name of the associated custom node in the Visual Shader Editor’s members dialog and graph.
Defining this method is optional, but recommended. If not overridden, the node will be named as “Unnamed”.
fn get_description(&self) -> GString
fn get_description(&self) -> GString
Override this method to define the description of the associated custom node in the Visual Shader Editor’s members dialog.
Defining this method is optional.
fn get_category(&self) -> GString
fn get_category(&self) -> GString
Override this method to define the path to the associated custom node in the Visual Shader Editor’s members dialog. The path may look like "MyGame/MyFunctions/Noise".
Defining this method is optional. If not overridden, the node will be filed under the “Addons” category.
fn get_return_icon_type(&self) -> PortType
fn get_return_icon_type(&self) -> PortType
Override this method to define the return icon of the associated custom node in the Visual Shader Editor’s members dialog.
Defining this method is optional. If not overridden, no return icon is shown.
fn get_input_port_count(&self) -> i32
fn get_input_port_count(&self) -> i32
Override this method to define the number of input ports of the associated custom node.
Defining this method is required. If not overridden, the node has no input ports.
fn get_input_port_type(&self, port: i32) -> PortType
fn get_input_port_type(&self, port: i32) -> PortType
Override this method to define the returned type of each input port of the associated custom node.
Defining this method is optional, but recommended. If not overridden, input ports will return the PortType::SCALAR type.
fn get_input_port_name(&self, port: i32) -> GString
fn get_input_port_name(&self, port: i32) -> GString
Override this method to define the names of input ports of the associated custom node. The names are used both for the input slots in the editor and as identifiers in the shader code, and are passed in the input_vars array in get_code.
Defining this method is optional, but recommended. If not overridden, input ports are named as "in" + str(port).
fn get_input_port_default_value(&self, port: i32) -> Variant
fn get_input_port_default_value(&self, port: i32) -> Variant
Override this method to define the default value for the specified input port. Prefer use this over set_input_port_default_value.
Defining this method is required. If not overridden, the node has no default values for their input ports.
fn get_default_input_port(&self, type_: PortType) -> i32
fn get_default_input_port(&self, type_: PortType) -> i32
Override this method to define the input port which should be connected by default when this node is created as a result of dragging a connection from an existing node to the empty space on the graph.
Defining this method is optional. If not overridden, the connection will be created to the first valid port.
fn get_output_port_count(&self) -> i32
fn get_output_port_count(&self) -> i32
Override this method to define the number of output ports of the associated custom node.
Defining this method is required. If not overridden, the node has no output ports.
fn get_output_port_type(&self, port: i32) -> PortType
fn get_output_port_type(&self, port: i32) -> PortType
Override this method to define the returned type of each output port of the associated custom node.
Defining this method is optional, but recommended. If not overridden, output ports will return the PortType::SCALAR type.
fn get_output_port_name(&self, port: i32) -> GString
fn get_output_port_name(&self, port: i32) -> GString
Override this method to define the names of output ports of the associated custom node. The names are used both for the output slots in the editor and as identifiers in the shader code, and are passed in the output_vars array in get_code.
Defining this method is optional, but recommended. If not overridden, output ports are named as "out" + str(port).
fn get_property_count(&self) -> i32
fn get_property_count(&self) -> i32
Override this method to define the number of the properties.
Defining this method is optional.
fn get_property_name(&self, index: i32) -> GString
fn get_property_name(&self, index: i32) -> GString
Override this method to define the names of the property of the associated custom node.
Defining this method is optional.
fn get_property_default_index(&self, index: i32) -> i32
fn get_property_default_index(&self, index: i32) -> i32
Override this method to define the default index of the property of the associated custom node.
Defining this method is optional.
fn get_property_options(&self, index: i32) -> PackedArray<GString>
fn get_property_options(&self, index: i32) -> PackedArray<GString>
Override this method to define the options inside the drop-down list property of the associated custom node.
Defining this method is optional.
fn get_code(
&self,
input_vars: Array<GString>,
output_vars: Array<GString>,
mode: Mode,
type_: Type,
) -> GString
fn get_code( &self, input_vars: Array<GString>, output_vars: Array<GString>, mode: Mode, type_: Type, ) -> GString
Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the """ multiline string construct can be used for convenience).
The input_vars and output_vars arrays contain the string names of the various input and output variables, as defined by _get_input_* and _get_output_* virtual methods in this class.
The output ports can be assigned values in the shader code. For example, return output_vars[0] + " = " + input_vars[0] + ";".
You can customize the generated code based on the shader mode and/or type.
Defining this method is required.
fn get_func_code(&self, mode: Mode, type_: Type) -> GString
fn get_func_code(&self, mode: Mode, type_: Type) -> GString
Override this method to add a shader code to the beginning of each shader function (once). The shader code should be returned as a string, which can have multiple lines (the """ multiline string construct can be used for convenience).
If there are multiple custom nodes of different types which use this feature the order of each insertion is undefined.
You can customize the generated code based on the shader mode and/or type.
Defining this method is optional.
fn get_global_code(&self, mode: Mode) -> GString
fn get_global_code(&self, mode: Mode) -> GString
Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the """ multiline string construct can be used for convenience).
Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names.
You can customize the generated code based on the shader mode.
Defining this method is optional.
fn is_highend(&self) -> bool
fn is_highend(&self) -> bool
Override this method to enable the high-end mark in the Visual Shader Editor’s members dialog. This should return true for nodes that only work when using the Forward+ and Mobile renderers.
Defining this method is optional. If not overridden, it’s false, which indicates this node works with all renderers (including Compatibility).
fn is_available(&self, mode: Mode, type_: Type) -> bool
fn is_available(&self, mode: Mode, type_: Type) -> bool
Override this method to prevent the node to be visible in the member dialog for the certain mode and/or type.
Defining this method is optional. If not overridden, it’s true.
fn setup_local_to_scene(&mut self)
fn setup_local_to_scene(&mut self)
Override this method to customize the newly duplicated resource created from instantiate, if the original’s [member resource_local_to_scene] is set to true.
Example: Set a random damage value to every local resource from an instantiated scene:
extends Resource
var damage = 0
func _setup_local_to_scene():
damage = randi_range(10, 40)fn reset_state(&mut self)
fn reset_state(&mut self)
For resources that store state in non-exported properties, such as via on_validate_property or on_get_property_list, this method must be implemented to clear them.
fn set_path_cache(&self, path: GString)
fn set_path_cache(&self, path: GString)
Override this method to execute additional logic after set_path_cache is called on this object.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.