# EditorToolContext

> Use this class to implement specialized versions of the built-in transform tools. Built-in transform tools include Move, Rotate, Scale, Rect, and Transform.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.EditorTools](/engine/6000.5/script-reference/unityeditor/editortools.md)
* **Assembly:** UnityEditor.CoreModule
* **Inherits from:** [ScriptableObject](/engine/6000.5/script-reference/unityengine/scriptableobject.md)

```csharp
public abstract class EditorToolContext : ScriptableObject
```

## Examples

```csharp
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.EditorTools;
using UnityEngine;
// EditorToolContextAttribute is what registers a context with the UI.
[EditorToolContext("Wobbly Transform Tools")]
// The icon path can also be used with packages. Ex "Packages/com.wobblestudio.wobblytools/Icons/Transform.png".
[Icon("Assets/Examples/Icons/TransformIcon.png")]
public class WobbleContext : EditorToolContext
{
    // Tool contexts can also implement an OnToolGUI function that is invoked before tools. This is a good place to
    // add any custom selection logic, for example.
    public override void OnToolGUI(EditorWindow _) { }
    protected override Type GetEditorToolType(Tool tool)
    {
        switch (tool)
        {
            // Return the type of tool to be used for Tool.Move. The Tool Manager will handle instantiating and
            // activating the tool.
            case Tool.Move:
                return typeof(WobblyMoveTool);
            // For any tools that are not implemented, return null to disable the tool in the menu.
            default:
                return null;
        }
    }
}
// Note that tools used by an EditorToolContext do not need to use EditorToolAttribute.
class WobblyMoveTool : EditorTool
{
    struct Selected
    {
        public Transform transform;
        public Vector3 localScale;
    }
    Vector3 m_Origin;
    List<Selected> m_Selected = new List<Selected>();
    void StartMove(Vector3 origin)
    {
        m_Origin = origin;
        m_Selected.Clear();
        foreach(var trs in Selection.transforms)
            m_Selected.Add(new Selected() { transform = trs, localScale = trs.localScale });
        Undo.RecordObjects(Selection.transforms, "Wobble Move Tool");
    }
    // This is silly example that oscillates the scale of the selected objects as they are moved.
    public override void OnToolGUI(EditorWindow _)
    {
        var evt = Event.current.type;
        var hot = GUIUtility.hotControl;
        EditorGUI.BeginChangeCheck();
        var p = Handles.PositionHandle(Tools.handlePosition, Tools.handleRotation);
        if (evt == EventType.MouseDown && hot != GUIUtility.hotControl)
            StartMove(p);
        if (EditorGUI.EndChangeCheck())
        {
            foreach (var selected in m_Selected)
            {
                selected.transform.position += (p - Tools.handlePosition);
                var scale = Vector3.one * (Mathf.Sin(Mathf.Abs(Vector3.Distance(m_Origin, p))) * .5f);
                selected.transform.localScale = selected.localScale + scale;
            }
        }
    }
}
```

## Properties

| Property                                                                                                                            | Description                                             |
| ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| [overridesDefaultSelection](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/overridesdefaultselection.md) | Whether the tool context overrides the scene selection. |
| [target](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/target.md)                                       | The object being inspected.                             |
| [targets](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/targets.md)                                     | An array of the objects being inspected.                |

## Methods

| Method                                                                                                                        | Description                                                                                                                                                                                                    |
| ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [GetAdditionalToolTypes](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/getadditionaltooltypes.md) | Get an additional collection of tools to display in the same category as the built-in transform tools.                                                                                                         |
| [GetEditorToolType](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/geteditortooltype.md)           | Defines the [EditorTool](/engine/6000.5/script-reference/unityeditor/editortools/editortool.md) type for a given [Tool](/engine/6000.5/script-reference/unityeditor/tool.md).                                  |
| [OnActivated](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/onactivated.md)                       | Invoked after this [EditorToolContext](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext.md) becomes the active tool context.                                                          |
| [OnToolGUI](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/ontoolgui.md)                           | Implements any common functionality for the set of manipulation tools available for this context.                                                                                                              |
| [OnWillBeDeactivated](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/onwillbedeactivated.md)       | Invoked before this [EditorToolContext](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext.md) stops being the active tool context.                                                     |
| [PopulateMenu](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/populatemenu.md)                     | Adds menu items to the Scene view context menu.                                                                                                                                                                |
| [ResolveTool](/engine/6000.5/script-reference/unityeditor/editortools/editortoolcontext/resolvetool.md)                       | Returns the matching [EditorTool](/engine/6000.5/script-reference/unityeditor/editortools/editortool.md) type for the specified [Tool](/engine/6000.5/script-reference/unityeditor/tool.md) given the context. |

## Inheritance

**Inherited Members:**

* [ScriptableObject.CreateInstance(string)](/engine/6000.5/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(string\))
* [ScriptableObject.CreateInstance(Type)](/engine/6000.5/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(type\))
* [ScriptableObject.CreateInstance\<T>()](/engine/6000.5/script-reference/unityengine/scriptableobject/createinstance.md)
* [Object.GetEntityId()](/engine/6000.5/script-reference/unityengine/object/getentityid.md)
* [Object.GetHashCode()](/engine/6000.5/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.5/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.5/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type)](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type\))
* [Object.FindObjectsByType(Type, FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.5/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindAnyObjectByType\<T>()](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindObjectsByType\<T>()](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.5/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.5/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.5/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.5/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.5/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.5/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
