I want to delete an entity from the screen on the click of the delete button present in the 2D screen on the app. I have added the following script in the ‘root’ of the app. Can someone help me why this is not working and how to make it work?
I’m thinking most likely that’s coming because entities are being created/added to the hierarchy from top to bottom. So at the moment your script runs the entity you are looking for doesn’t exist yet.
You can solve that in two ways:
Replace initialize with postInitialize in line 4.
Instead of running your script on Root, add an entity at the bottom of your scene hierarchy and add your script to it.
//after raycast store it as:
window.__pickedEntity.active = result.entity;
I want to delete the entity from the scene once the __pickedEntity.active contains an entity, ie the user clicks on an entity from the scene and then clicks on the delete button.