Gdevelop: Hidden layer object's are interactive where as i t should not in the IDE

Created on 23 Sep 2018  路  11Comments  路  Source: 4ian/GDevelop

Description

If you have for example multiple layers, with objects on it, and if you choose to hide one layer (in IDE (not ingame or game preview)), the object of the hidden layer can still be selected/edited.

I'm almost sure it's not normal and GD4 was not acting like this. It's disturbing because you can't just work on a layer since hidden objects react on mouse over and mouse click.

To Reproduce

Steps to reproduce the behavior:

  1. Create 2 layers
  2. Put objects on both layers
  3. Hide one of the layer
  4. Select (mouse selection a zone) or just move the mouse around : hidden object react while it should'nt

OS : Windows 10
GD 5.52

馃悰 bug 馃槫Non optimal UI behavior

Most helpful comment

Ok, I fixed this bug. Will do a pull request later today after work :)

All 11 comments

confirmed.. might give this a try later if nobody else picks it up :)

It's indeed a bug, @blurymind feel free to look at this otherwise I'll try to fix this later this week

@4ian from what I understand, when selection is made, we need to check if the instance is on a hidden layer.
I get the layer's name with getLayer() method, but what I really need is to see if that layer isVisible().
What is the best way to do that?

The information is in props.layout, which contains getLayer (to get a layer) and getLayersCount + getLayerAt (to iterate over layer), and gd.Layer contain getVisibility method.
Would be great though to not call getVisibility every time for every object, there is maybe a helper function to be done that returns an array/object containing layer names as key, and a "visible" boolean as value (for example {"": true, "GUI": false, "OtherLayer": true} for base layer and OtherLayer visible, but GUI layer hidden). Once we have this computed by the helper function, we can use these results anytime we call selectInstance or selectInstances (to exclude the objects that are on hidden layers).

@4ian That is a very good idea! What would be the best place to create that function? I've been adding these new util functions to Utils, but that seems more like a gui function

I think it can be in InstancesEditor/index.js for now, because it's the InstancesEditor that call selectInstance/selectInstances (if I'm not mistaken), so it's also this file that need to compute the layers hidden/shown and pass it to the selectXXX methods.

@4ian thank you, I will give this a try. :)

It looks like they get added to the selection array in InstancesSelection. We could prevent that from happening in the first place right there? Will need to import props to it though

Ok, I fixed this bug. Will do a pull request later today after work :)

Thanks for working on this @blurymind! :)

hey no problem.Thank you for the feedback. This gave me some understanding of how instance selection works and actually makes me itch to implement #670 , but wont try that without your blessing :)

Was this page helpful?
0 / 5 - 0 ratings