Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

custom EditorTools Feedback

Discussion in 'Editor Workflows' started by usernameHed, Nov 15, 2020.

  1. usernameHed

    usernameHed

    Joined:
    Apr 5, 2016
    Posts:
    90
    Hello, I have 2 feedBack:

    - When you are using an EditorTools, when you enter inside the OnToolGUI(), we can not prevent the scrollWheel with Event.current.Use().
    I have to create a entier script that does just that:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.EditorTools;
    4.  
    5. namespace unityEssentials.editorTools.extensions
    6. {
    7.     [InitializeOnLoad]
    8.     public static class ObjectPlacerOverrideEvents
    9.     {
    10.         static ObjectPlacerOverrideEvents()
    11.         {
    12. #if UNITY_2019_1_OR_NEWER
    13.             SceneView.duringSceneGui += DuringSceneGUI;
    14. #else
    15.             SceneView.onSceneGUIDelegate += DuringSceneGUI;
    16. #endif
    17.         }
    18.  
    19.         private static void DuringSceneGUI(SceneView sceneView)
    20.         {
    21.             bool isCurrentObjectPlacerTool = Tools.current == Tool.Custom && EditorTools.activeToolType == typeof(ObjectPlacer);
    22.             if (!isCurrentObjectPlacerTool)
    23.             {
    24.                 return;
    25.             }
    26.             if (Event.current.type == EventType.ScrollWheel)
    27.             {
    28.                 Event.current.Use();
    29.             }
    30.         }
    31.     }
    32. }
    - Secondly, I would like to be able to use the native Handle.Position / rotation when I am using certain type of tools.

    Like for my ObjectPlacer tool, witch is a local tool: I have my selected gameObject, and I would like to still have the native Handle.Position, while doing my stuff with my tool.

    Of course I could do my own, with Handles.Position and stuff, but by doing that, I break some other tools, that Rely on HandleUtility.nearestControl.

    I have 2 ideas:
    - when I am in my custom tools, I "triggger" the last native tool we were at (like the Move Tool for example).
    - second idea: inherite from Move, Rotate, Transform... but it's less convinient...

    And actually, I would like simple to be able to create custom tools that do NOT replace the other ones.... Because right now, I have 2 options: do my own tools, like always, and not use this new API. Or use it, but with less flexibility.
     
    Last edited: Nov 15, 2020
  2. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    600