55 */
66
77mod export;
8+ mod on_editor;
89mod signals;
910
1011use std:: marker:: PhantomData ;
@@ -18,6 +19,7 @@ use godot::prelude::{ConvertError, Gd, Object, StringName, Variant};
1819pub use crate :: runtime:: Context ;
1920
2021pub use export:: GodotScriptExport ;
22+ pub use on_editor:: OnEditor ;
2123#[ expect( deprecated) ]
2224pub use signals:: { ScriptSignal , Signal } ;
2325
@@ -135,6 +137,20 @@ impl<T: GodotScript> ToGodot for RsRef<T> {
135137 }
136138}
137139
140+ impl < ' v , T : GodotScript > :: godot:: prelude:: Var for RsRef < T >
141+ where
142+ Self : GodotConvert < Via = <Self as ToGodot >:: ToVia < ' v > > ,
143+ Self : ' v ,
144+ {
145+ fn get_property ( & self ) -> Self :: Via {
146+ <Self as ToGodot >:: to_godot ( self )
147+ }
148+
149+ fn set_property ( & mut self , value : Self :: Via ) {
150+ <Self as FromGodot >:: from_godot ( value) ;
151+ }
152+ }
153+
138154#[ derive( thiserror:: Error , Debug ) ]
139155pub enum GodotScriptCastError {
140156 #[ error( "Object has no script attached!" ) ]
@@ -196,6 +212,59 @@ impl<T: GodotScript, B: Inherits<T::Base> + Inherits<Object>> CastToScript<T> fo
196212 }
197213}
198214
215+ /// Script property access indirection
216+ ///
217+ /// gdext uses this kind of indirection to allow conversion of the actual property value into a godot compatible type when accessing the
218+ /// property from the engine. This Trait separates the `::godot::prelude::Var` trait into it's get and set components for more granular
219+ /// requirements on the property types.
220+ pub trait GetScriptProperty : GodotConvert {
221+ fn get_property ( & self ) -> Self :: Via ;
222+ }
223+
224+ /// Script property write indirection
225+ ///
226+ /// gdext uses this kind of indirection to allow conversion of the actual property value from a godot compatible type when setting the
227+ /// property from the engine. This Trait separates the `::godot::prelude::Var` trait into it's get and set components for more granular
228+ /// requirements on the property types.
229+ pub trait SetScriptProperty : GodotConvert {
230+ fn set_property ( & mut self , value : Self :: Via ) ;
231+ }
232+
233+ /// Unified property init strategy.
234+ ///
235+ /// Most of the time we can initialize a script property with the `Default` trait. To support cases where `Default` is not implemented we
236+ /// can manually implement this trait.
237+ pub trait InitScriptProperty {
238+ fn init_property ( ) -> Self ;
239+ }
240+
241+ impl < T > GetScriptProperty for T
242+ where
243+ T : godot:: prelude:: Var ,
244+ {
245+ fn get_property ( & self ) -> Self :: Via {
246+ T :: get_property ( self )
247+ }
248+ }
249+
250+ impl < T > SetScriptProperty for T
251+ where
252+ T : godot:: prelude:: Var ,
253+ {
254+ fn set_property ( & mut self , value : Self :: Via ) {
255+ T :: set_property ( self , value) ;
256+ }
257+ }
258+
259+ impl < T > InitScriptProperty for T
260+ where
261+ T : Default ,
262+ {
263+ fn init_property ( ) -> Self {
264+ Default :: default ( )
265+ }
266+ }
267+
199268#[ macro_export]
200269macro_rules! define_script_root {
201270 ( ) => {
0 commit comments