Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Handles.ArrowCap

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function ArrowCap(controlID: int, position: Vector3, rotation: Quaternion, size: float): void;
public static void ArrowCap(int controlID, Vector3 position, Quaternion rotation, float size);

Parameters

controlID The control ID for the handle.
position The world-space position of the handle's start point.
rotation The rotation of the handle.
size The size of the handle in world-space units.

Description

Draw an arrow like those used by the move tool.

Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.


Arrow Cap in the Scene View.

To use this example, save this script in your Assets/Editor folder:

#pragma strict
@CustomEditor(DummyArrowCap)
public class ArrowCapEditor extends Editor {
	public var arrowSize: float = 1;
	function OnSceneGUI() {
		var t: DummyArrowCap = target as DummyArrowCap;
		Handles.color = Handles.xAxisColor;
		Handles.ArrowCap(0, t.transform.position, t.transform.rotation * Quaternion.Euler(0, 90, 0), arrowSize);
		Handles.color = Handles.yAxisColor;
		Handles.ArrowCap(0, t.transform.position, t.transform.rotation * Quaternion.Euler(-90, 0, 0), arrowSize);
		Handles.color = Handles.zAxisColor;
		Handles.ArrowCap(0, t.transform.position, t.transform.rotation, arrowSize);
	}
}
using UnityEngine;
using UnityEditor;

[CustomEditor( typeof( DummyArrowCap ) )] public class ArrowCapEditor : Editor { public float arrowSize = 1;

void OnSceneGUI( ) { DummyArrowCap t = target as DummyArrowCap;

Handles.color = Handles.xAxisColor; Handles.ArrowCap( 0, t.transform.position, t.transform.rotation * Quaternion.Euler( 0, 90, 0 ), arrowSize );

Handles.color = Handles.yAxisColor; Handles.ArrowCap( 0, t.transform.position, t.transform.rotation * Quaternion.Euler( -90, 0, 0 ), arrowSize );

Handles.color = Handles.zAxisColor; Handles.ArrowCap( 0, t.transform.position, t.transform.rotation, arrowSize ); } }

...and attach this script to the object you wish to display the Arrow Caps on.

#pragma strict
@ExecuteInEditMode
public class DummyArrowCap extends MonoBehaviour {
	public function Start() {
		Debug.Log("I have ArrowCap Handles attached to this transform!");
	}
}
using UnityEngine;

[ExecuteInEditMode] public class DummyArrowCap : MonoBehaviour { public void Start( ) { Debug.Log( "I have ArrowCap Handles attached to this transform!" ); } }