You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Use this derive macro to create new rust scripts for your projects.
24
+
///
25
+
/// The macro is desinged to closely align with both godot-rusts [`GodotClass`](https://docs.rs/godot/latest/godot/prelude/derive.GodotClass.html) macro and the GDScript
26
+
/// annotations.
27
+
///
28
+
/// # Top Level Attribute
29
+
/// On the struct level the `#[script]` attribute can be used to configure base details of the script.
30
+
///
31
+
/// ## `#[script(base)]`
32
+
/// ```
33
+
/// # use ::godot_rust_script::{GodotScript, godot_script_impl};
34
+
/// # use ::godot::classes::Node3D;
35
+
/// #
36
+
/// #[derive(GodotScript, Debug)]
37
+
/// #[script(base = Node3D)]
38
+
/// struct MyScript {}
39
+
///
40
+
/// # #[godot_script_impl]
41
+
/// # impl MyScript {}
42
+
/// ```
43
+
///
44
+
/// Set the `base` field to specify a base class your script should inherit from. By default all scripts inherit from [`RefCounted`](https://docs.rs/godot/latest/godot/classes/struct.RefCounted.html).
45
+
///
46
+
/// # Field Level Attributes
47
+
/// On the field level you can specify customizations for your script properties. Fields that are private will not be exposed to the engine.
48
+
/// Public field on the other hand are exposed to the engine and can be annotated with attributes.
49
+
///
50
+
/// ## `#[prop]`
51
+
/// Use the `#[prop]` attribute to set up getter and setter functions for your properties.
52
+
///
53
+
/// ```
54
+
/// # use godot_rust_script::{GodotScript, godot_script_impl};
55
+
/// # use godot::builtin::GString;
56
+
/// #
57
+
/// #[derive(GodotScript, Debug)]
58
+
/// struct MyScript {
59
+
/// #[prop(set = Self::set_my_prop, get = Self::get_my_prop)]
60
+
/// my_prop: GString,
61
+
/// }
62
+
///
63
+
/// #[godot_script_impl]
64
+
/// impl MyScript {
65
+
/// fn set_my_prop(&mut self, value: GString) {
66
+
/// self.my_prop = value;
67
+
/// }
68
+
///
69
+
/// fn get_my_prop(&self) -> GString {
70
+
/// self.my_prop.clone()
71
+
/// }
72
+
/// }
73
+
/// ```
74
+
///
75
+
/// This attribute optionally accepts a `get` and a `set` field. If these fields are defined they have to be set to a function pointer
76
+
/// expression. The expression can contain the `Self` keyword.
0 commit comments