[SOLVED] Editor scripting question

How is the item selected? I do understand that it is on ‘mouseup’ but how does it get displayed in ‘inspector’ view and stays selected in ‘hierarchy’?

I can get the currently selected item with:

let lockedSelection = editor.selection.item // or editor.selection.items[0] if there are multiple

But how would I go about setting the entity that I want. This is what I thought I had to do:

editor.selection.set(lockedSelection) 

But that’s not it. Is there a specific event that I need to prevent from firing for the the selection to not change/or to fire an event to change back to lockedSelection?

Figured out a workaround, I can just suspend the event for listening to selection mouse clicks like this:

editor.selection.suspendEvents = true; // Change to false if you want to unsuspend events.

The above solution doesn’t work very well since you can still ‘click’ on other entities and hierarchy which means you will still deselect/select other entities in the world.


Below solution works very well since you can’t select other objects until you enable it again!

editor.selection.enabled = false; // Change to true to allow selection agan

Cool :smiley:

2 Likes