Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Custom editor tool with componnet doesn't always show

Discussion in 'Editor Workflows' started by Piotr_Haryza, Jul 13, 2023.

  1. Piotr_Haryza

    Piotr_Haryza

    Joined:
    Jan 4, 2019
    Posts:
    2
    Hello,
    I'm using unity version 2021.3.7f1. This is important as there is a bug https://issuetracker.unity3d.com/issues/editortoolattribute-changed-incompatibly which may be causing this (but there is no description so i dont know)

    I'm writing custom editor tool for a component.

    Code (CSharp):
    1. [EditorTool("Road creation Tool", componentToolTarget:typeof(RtsMap))]
    2. class CreateJunctionRoadTool : EditorTool, IDrawSelectedHandles
    3. {
    4. ...
    5. }
    The problem is visibility/availability of this tool is not consistent when working with multiple inspectors (some of them locked)

    It is possible to have selected gameobject with RtsMap component and tool is sometimes visible, but sometimes it isn't. Also visibility of the toos is not connected with object available in UnityEditor.Selection.
    activeObject as tool could be visible or not visible when gameobject with correct component is selected.

    Could someone explain how it should work / what other options could be used for consistent tool availability?