Hi everyone, in my project I’m importing a JSON file that lists several objects, each of which contains a property that corresponds to a list of 6 “dices”. I’ve organized each Dice graphically in an external layout, so for each iteration of these elements and for each of them, I create objects from the external layout. For each creation, there’s a subevent where I apply the text value I’m interested in to a Text object (according to the documentation, object picking only works as a subevent).
What is the expected result
For each created object, each Text instance should have the appropriate value.
What is the actual result
The text value of the Text object always corresponds to the last iterated value (but if I do a console log of the text value and the extracted value, it’s correct; only in the rendering does it correspond to the last value).
yes, exactly. Every field must be different. Here you are a screenshot of console log of what i need as value. The strange thing is that works if i print on console, but not on the render. Seems to be replaced in every iteration
Even if that was the Text attribute of Txt, it still wouldn’t work - there is no condition on the event or the parent events to restrict which Txt object to update. So GDevelop does them all, with the same value.
Ha, and just after I sent the reply I spotted that you set Txt.Text = Txt.Content. SMH at myself.
You won’t need to create them in the event sheet if you uniquely identify them in the external layout, but in a way that it can be easily determined what the Id is.
Could you suggest to me a better approach? If you are talking about applying a Id in creation I cannot do it because I could be the same problem with the text value
But I’d personally go for creating the objects in your scene events. That way if the number of abilities change, then you don’t have to add or remove any objects or Ids.
Hi again, I changed approach using Prefabs that I dind’t remember about this feature is already active! That is awesome. With prefabs works! Thanks for help @MrMen