Unity: Editor helper class
Une helper class dédié à la personalisation de l’éditeur dans Unity. Cette classe sert à contenir un ensemble de fonctions utilitaires utiliser dans les scripts permettant de personnaliser l’interface de l’éditeur.
Update 10/03/2016 : Ajout de la fonction DrawArrow
using UnityEngine;
using UnityEditor;
using System.Collections;
/// <summary>
/// Editor helper. Static functions for doing recurents actions in the editor
/// </summary>
public class EditorHelper {
/// <summary>
/// Draws an arrow in a given direction.
/// </summary>
/// <param name="pos">Position from where start the arrow.</param>
/// <param name="direction">Direction of the arrow.</param>
/// <param name="color">Color of the arrow.</param>
/// <param name="headSize">Head size of the arrow.</param>
public static void DrawArrow(Vector3 pos, Vector3 direction, Color? color = null, float headSize = 0.25f) {
Color initialColor = Handles.color;
if(color != null) {
Handles.color = color.Value;
}
Handles.DrawLine(pos, pos+direction);
Handles.ConeCap(0, pos+direction, Quaternion.LookRotation(direction), headSize);
Handles.color = initialColor;
}
}