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.
19
+
///
20
+
/// 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
21
+
/// annotations.
22
+
///
23
+
/// # Top Level Attribute
24
+
/// On the struct level the `#[script]` attribute can be used to configure base details of the script.
25
+
///
26
+
/// ## `#[script(base)]`
27
+
/// ```
28
+
/// # use godot_rust_script::{GodotScript, godot_script_impl};
29
+
/// # use godot::classes::Node3D;
30
+
/// #
31
+
/// #[derive(GodotScript, Debug)]
32
+
/// #[script(base = Node3D)]
33
+
/// struct MyScript {}
34
+
///
35
+
/// # #[godot_script_impl]
36
+
/// # impl MyScript {}
37
+
/// ```
38
+
///
39
+
/// 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).
40
+
///
41
+
/// # Field Level Attributes
42
+
/// On the field level you can specify customizations for your script properties. Fields that are private will not be exposed to the engine.
43
+
/// Public field on the other hand are exposed to the engine and can be annotated with attributes.
44
+
///
45
+
/// ## `#[prop]`
46
+
/// Use the `#[prop]` attribute to set up getter and setter functions for your properties.
47
+
///
48
+
/// ```
49
+
/// # use godot_rust_script::{GodotScript, godot_script_impl};
50
+
/// # use godot::builtin::GString;
51
+
/// #
52
+
/// #[derive(GodotScript, Debug)]
53
+
/// struct MyScript {
54
+
/// #[prop(set = Self::set_my_prop, get = Self::get_my_prop)]
55
+
/// my_prop: GString,
56
+
/// }
57
+
///
58
+
/// #[godot_script_impl]
59
+
/// impl MyScript {
60
+
/// fn set_my_prop(&mut self, value: GString) {
61
+
/// self.my_prop = value;
62
+
/// }
63
+
///
64
+
/// fn get_my_prop(&self) -> GString {
65
+
/// self.my_prop.clone()
66
+
/// }
67
+
/// }
68
+
/// ```
69
+
///
70
+
/// This attribute optionally accepts a `get` and a `set` field. If these fields are defined they have to be set to a function pointer
71
+
/// expression. The expression can contain the `Self` keyword.
0 commit comments