# CustomPivotAttribute

> Registers a CustomPivotMode or CustomPivotRotation as a custom editor pivot setting. Use the PivotManager API or the Tool Settings overlay's UI to activate a registered setting.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.EditorTools](/engine/6000.5/script-reference/unityeditor/editortools.md)
* **Assembly:** UnityEditor.CoreModule
* **Inherits from:** [Attribute](https://learn.microsoft.com/dotnet/api/system.attribute)

```csharp
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class CustomPivotAttribute : Attribute
```

## Examples

```csharp
using UnityEditor;
using UnityEngine;
using UnityEditor.EditorTools;

// Register a custom Pivot Mode that places the tool handle at the top middle point of the active object's local bounds.
// This Pivot Mode will be available for any tool or context as neither the targetTool nor targetToolContext are specified.
[CustomPivot(k_DisplayName, tooltip = k_Tooltip, priority = CustomPivotAttribute.defaultPriority + 2)]
[Icon(k_Icon)] // Use IconAttribute to customize pivot setting's icon
public sealed class TopPivotMode : CustomPivotMode
{
    const string k_DisplayName = "Top";
    const string k_Icon = "ToolHandleGlobal";
    const string k_Tooltip = "The tool handle is placed at the top middle point of active object's local bounds.";

    public override Vector3 position
    {
        get
        {
            Transform t = Selection.activeTransform;
            if (!t)
                return Vector3.zero;

            var renderer = t.GetComponent<MeshRenderer>();
            if (!renderer)
                return Vector3.zero;

            var localBounds = renderer.localBounds;
            var localTopPivot = new Vector3(localBounds.center.x, localBounds.max.y, localBounds.center.z);

            var topPivotPosition = t.TransformPoint(localTopPivot);
            return topPivotPosition;
        }
    }
}
```

```csharp
using UnityEditor;
using UnityEngine;
using UnityEditor.EditorTools;

// Register a custom Pivot Rotation that orients the tool handle to always face the Scene View's camera.
// This Pivot Rotation will be available for any tool or context as neither targetTool nor targetToolContext are specified.
[CustomPivot(k_DisplayName, tooltip = k_Tooltip, priority = CustomPivotAttribute.defaultPriority + 2)]
[Icon("ToolHandleGlobal")] // Use IconAttribute to customize pivot setting's icon
public sealed class ViewPivotRotation : CustomPivotRotation
{
    const string k_DisplayName = "View";
    const string k_Tooltip = "The tool handle is rotated to align with Scene View camera's orientation.";

    public override Quaternion rotation => SceneView.lastActiveSceneView.camera.transform.rotation;
}
```

## Static Fields

| Value                                                                                                              | Description                                                                                                                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [defaultPriority](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/defaultpriority.md) | The default value for [CustomPivotAttribute.priority](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/priority.md). Specify a priority lower than this value to display a pivot setting before the default entries, or specify a higher value to display it after the default entries. |

## Constructors

| Constructor                                                                                                                                         | Description                                                                                                                                                                                                                                                                  |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CustomPivotAttribute(System.String,System.Type,System.Type)](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/ctor.md) | Registers a [CustomPivotMode](/engine/6000.5/script-reference/unityeditor/custompivotmode.md) or [CustomPivotRotation](/engine/6000.5/script-reference/unityeditor/custompivotrotation.md) as an additional option to the Editor's built-in pivot mode or rotation settings. |

## Properties

| Property                                                                                                               | Description                                                                                                                                                                                                        |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [displayName](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/displayname.md)             | The name to display for this pivot setting in the Editor's UI.                                                                                                                                                     |
| [priority](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/priority.md)                   | Priority defines the order to display the pivot settings in within the Tools Settings overlay's dropdown menus.                                                                                                    |
| [targetTool](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/targettool.md)               | If provided, the pivot setting is only available when the [ToolManager.activeToolType](/engine/6000.5/script-reference/unityeditor/editortools/toolmanager/activetooltype.md) is equal to targetTool.              |
| [targetToolContext](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/targettoolcontext.md) | If provided, the pivot setting is only available when the [ToolManager.activeContextType](/engine/6000.5/script-reference/unityeditor/editortools/toolmanager/activecontexttype.md) is equal to targetToolContext. |
| [tooltip](/engine/6000.5/script-reference/unityeditor/editortools/custompivotattribute/tooltip.md)                     | The tooltip to display in the Editor's UI for this pivot setting.                                                                                                                                                  |

## Inheritance

**Inherited Members:**

* [Attribute.GetCustomAttributes(MemberInfo, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-memberinfo-system-type\))
* [Attribute.GetCustomAttributes(MemberInfo, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-memberinfo-system-type-system-boolean\))
* [Attribute.GetCustomAttributes(MemberInfo)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-memberinfo\))
* [Attribute.GetCustomAttributes(MemberInfo, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-memberinfo-system-boolean\))
* [Attribute.IsDefined(MemberInfo, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-memberinfo-system-type\))
* [Attribute.IsDefined(MemberInfo, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-memberinfo-system-type-system-boolean\))
* [Attribute.GetCustomAttribute(MemberInfo, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-memberinfo-system-type\))
* [Attribute.GetCustomAttribute(MemberInfo, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-memberinfo-system-type-system-boolean\))
* [Attribute.GetCustomAttributes(ParameterInfo)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-parameterinfo\))
* [Attribute.GetCustomAttributes(ParameterInfo, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-parameterinfo-system-type\))
* [Attribute.GetCustomAttributes(ParameterInfo, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-parameterinfo-system-type-system-boolean\))
* [Attribute.GetCustomAttributes(ParameterInfo, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-parameterinfo-system-boolean\))
* [Attribute.IsDefined(ParameterInfo, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-parameterinfo-system-type\))
* [Attribute.IsDefined(ParameterInfo, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-parameterinfo-system-type-system-boolean\))
* [Attribute.GetCustomAttribute(ParameterInfo, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-parameterinfo-system-type\))
* [Attribute.GetCustomAttribute(ParameterInfo, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-parameterinfo-system-type-system-boolean\))
* [Attribute.GetCustomAttributes(Module, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-module-system-type\))
* [Attribute.GetCustomAttributes(Module)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-module\))
* [Attribute.GetCustomAttributes(Module, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-module-system-boolean\))
* [Attribute.GetCustomAttributes(Module, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-module-system-type-system-boolean\))
* [Attribute.IsDefined(Module, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-module-system-type\))
* [Attribute.IsDefined(Module, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-module-system-type-system-boolean\))
* [Attribute.GetCustomAttribute(Module, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-module-system-type\))
* [Attribute.GetCustomAttribute(Module, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-module-system-type-system-boolean\))
* [Attribute.GetCustomAttributes(Assembly, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-assembly-system-type\))
* [Attribute.GetCustomAttributes(Assembly, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-assembly-system-type-system-boolean\))
* [Attribute.GetCustomAttributes(Assembly)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-assembly\))
* [Attribute.GetCustomAttributes(Assembly, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattributes#system-attribute-getcustomattributes\(system-reflection-assembly-system-boolean\))
* [Attribute.IsDefined(Assembly, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-assembly-system-type\))
* [Attribute.IsDefined(Assembly, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.isdefined#system-attribute-isdefined\(system-reflection-assembly-system-type-system-boolean\))
* [Attribute.GetCustomAttribute(Assembly, Type)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-assembly-system-type\))
* [Attribute.GetCustomAttribute(Assembly, Type, bool)](https://learn.microsoft.com/dotnet/api/system.attribute.getcustomattribute#system-attribute-getcustomattribute\(system-reflection-assembly-system-type-system-boolean\))
* [Attribute.Equals(Object)](https://learn.microsoft.com/dotnet/api/system.attribute.equals)
* [Attribute.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.attribute.gethashcode)
* [Attribute.Match(Object)](https://learn.microsoft.com/dotnet/api/system.attribute.match)
* [Attribute.IsDefaultAttribute()](https://learn.microsoft.com/dotnet/api/system.attribute.isdefaultattribute)
* [Attribute.TypeId()](https://learn.microsoft.com/dotnet/api/system.attribute.typeid)
