diff options
Diffstat (limited to 'scene/2d/light_2d.cpp')
-rw-r--r-- | scene/2d/light_2d.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 852a6fb46b..9715afeaa4 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -34,10 +34,19 @@ Rect2 Light2D::get_item_rect() const { } +void Light2D::_update_light_visibility() { + + if (!is_inside_tree()) + return; + + VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible()); +} + void Light2D::set_enabled( bool p_enabled) { - VS::get_singleton()->canvas_light_set_enabled(canvas_light,p_enabled); + enabled=p_enabled; + _update_light_visibility(); } bool Light2D::is_enabled() const { @@ -253,16 +262,22 @@ void Light2D::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { VS::get_singleton()->canvas_light_attach_to_canvas( canvas_light, get_canvas() ); + _update_light_visibility(); } if (p_what==NOTIFICATION_TRANSFORM_CHANGED) { VS::get_singleton()->canvas_light_set_transform( canvas_light, get_global_transform()); } + if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + + _update_light_visibility(); + } if (p_what==NOTIFICATION_EXIT_TREE) { VS::get_singleton()->canvas_light_attach_to_canvas( canvas_light, RID() ); + _update_light_visibility(); } } @@ -333,7 +348,7 @@ void Light2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale")); ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy"),_SCS("set_energy"),_SCS("get_energy")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix"),_SCS("set_mode"),_SCS("get_mode")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_SCS("set_height"),_SCS("get_height")); ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min")); ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max")); @@ -349,6 +364,7 @@ void Light2D::_bind_methods() { BIND_CONSTANT( MODE_ADD ); BIND_CONSTANT( MODE_SUB ); BIND_CONSTANT( MODE_MIX ); + BIND_CONSTANT( MODE_MASK ); } |