Use this class to implement custom editor tools. This is the base class from which all editor tools are inherited.
Use this class with EditorToolAttribute to register custom editor tools with the Editor.
using System; using UnityEngine; using UnityEditor; using UnityEditor.EditorTools;
// Tagging a class with the EditorTool attribute and no target type registers a global tool. Global tools are valid for any selection, and are accessible through the top left toolbar in the editor. [EditorTool("Platform Tool")] class PlatformTool : EditorTool { // Serialize this value to set a default value in the Inspector. [SerializeField] Texture2D m_ToolIcon;
GUIContent m_IconContent;
void OnEnable() { m_IconContent = new GUIContent() { image = m_ToolIcon, text = "Platform Tool", tooltip = "Platform Tool" }; }
public override GUIContent toolbarIcon { get { return m_IconContent; } }
// This is called for each window that your tool is active in. Put the functionality of your tool here. public override void OnToolGUI(EditorWindow window) { EditorGUI.BeginChangeCheck();
Vector3 position = Tools.handlePosition;
using (new Handles.DrawingScope(Color.green)) { position = Handles.Slider(position, Vector3.right); }
if (EditorGUI.EndChangeCheck()) { Vector3 delta = position - Tools.handlePosition;
Undo.RecordObjects(Selection.transforms, "Move Platform");
foreach (var transform in Selection.transforms) transform.position += delta; } } }
target | El objeto siendo inspeccionado. |
targets | An array of the objects being inspected. |
toolbarIcon | The icon and tooltip for this custom editor tool. If this function is not implemented, the toolbar displays the Inspector icon for the target type. If no target type is defined, the toolbar displays the Tool Mode icon. |
IsAvailable | Checks whether the custom editor tool is available based on the state of the editor. |
OnToolGUI | Use this method to implement a custom editor tool. |
hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
name | El nombre del objeto. |
GetInstanceID | Devuelve el id de la instancia del objeto. |
ToString | Returns the name of the object. |
Destroy | Removes a GameObject, component or asset. |
DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. |
DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. |
FindObjectOfType | Devuelve el primer objeto activo cargado de tipo type. |
FindObjectsOfType | Devuelve una lista de todos los objetos activos cargados de tipo type. |
Instantiate | Clona el objeto original y devuelve el clon. |
CreateInstance | Crea una instancia de un objeto scriptable. |
bool | ¿Existe el objeto? |
operator != | Compare si dos objetos se refieren a un objeto diferente. |
operator == | Compara dos referencias de objeto para ver si se refieren al mismo objeto. |
Awake | Esta función se llama cuando el script ScriptableObject empieza. |
OnDestroy | Esta función se llama cuando el objeto scriptable se destruirá. |
OnDisable | Esta función se llama cuando el objeto scriptable se va fuera del alcance (scope). |
OnEnable | Esta función se llama cuando el objeto es cargado. |