- Home /
Restrict Editor GameObject selection to GameObject with specific component
Hello,
I'm currently trying to do a simple staging system for a conversation system.
The idea is simple: Stage are simply slot for conversation that have a position + radius that I can modify through data StagePack are a list of "Stage" that contains all the stage (slot) of a conversation.
To do this, I created:
A StageComponent (containing the radius & some draw debug) + a "Stage" Prefab (for the position) Then the StagePack is a ScriptableObject that have a list of GameObject (the "Stage" prefab) and then I can call "InstanciateStages(NPC1, NPC2)" and it will Instantiate all Stages from the list.
Then only this that bother me is that "StagePack" has a list of "GameObject" that isn't very restrictive so someone could put every prefab he want...
Is there is a way to display here, only prefab that have the "StageComponent" and be more restrictive?
Thanks a lot
Answer by Adam-Mechtley · Sep 12, 2017 at 01:16 PM
Unfortunately this is not currently possible.
Even if you implement the suggestion from @H-Alex, you cannot filter assets in the object picker by component. The problem is that the components on the assets are not actually loaded into memory for the object selector, so that list would always be empty if you are in the Assets tab for the object selector.
(N.b., normally when you are picking scene objects from the Scene tab, even if the type is GameObject, you can do a filter in the search bar like "t:MyComponent").
Answer by H-Alex · Sep 12, 2017 at 01:11 PM
If I understand your question, maybe you should try having in your StagePack script a list of StageComponent instead of a list of gameobjects.
Already tried, but he won't show any prefabs or anything anymore, even the prefabs that have the StageComponent