Is it possible to create an overlay like the one shown here?
This is an overlay shown when a Tilemap component is in the scene.
When you deactivate the GameObject the tile map component is on, it disappears:
Additionally, it doesn’t appear in the overlay List:
Thank you, ChuanXin.
I’m have a bit of trouble getting it to work.
Could you please show me a bit of code?
You could implement ITransientOverlay.visible with something like below where your overlay would only show if your GameObject selection was enabled. You can modify it to check for other criteria, such as if it has a Tilemap component or otherwise.
public bool visible
{
get
{
return Selection.activeGameObject != null && Selection.activeGameObject.activeSelf;
}
}
4 Likes
You’re the best, ChuanXin.
Thank you!
For anyone else looking, this is how you do it:
[Overlay (typeof (SceneView), "MyOverlay", true)]
public class MyOverlay : Overlay, ITransientOverlay
{
// This bit is what makes it visible or not, based on whether this returns true or false
public bool visible
{
get
{
return
Selection.activeGameObject != null &&
Selection.activeGameObject.GetComponent <TileMaster> () != null; // Or whatever logic you want to dictate true or false
}
}
public override VisualElement CreatePanelContent ()
{
return new Button (); // Or whatever visual elects you want
}
}
4 Likes