Version: 2020.1
言語: 日本語

EditorTool

class in UnityEditor.EditorTools

/

継承:ScriptableObject

マニュアルに切り替える

説明

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ターゲットとなるオブジェクト
targetsAn array of the objects being inspected.
toolbarIconThe 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.

Public 関数

IsAvailableChecks whether the custom editor tool is available based on the state of the editor.
OnToolGUIUse this method to implement a custom editor tool.

継承メンバー

変数

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名

Public 関数

GetInstanceIDオブジェクトのインスタンス ID を返します
ToStringReturns the name of the object.

Static 関数

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeタイプ type から最初に見つけたアクティブのオブジェクトを返します
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiateoriginal のオブジェクトをクローンします
CreateInstanceScriptableObject のインスタンスを作成します。

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。

メッセージ

Awake ScriptableObject スクリプトを開始するとき、この関数は呼び出されます。
OnDestroyScriptableObject が破棄されるとき、この関数は呼び出されます。
OnDisableScriptableObject クラスのオブジェクトがスコープを外れるとき、この関数は呼び出されます。
OnEnableオブジェクトがロードされたとき、この関数は呼び出されます。
OnValidateThis function is called when the script is loaded or a value is changed in the Inspector (Called in the editor only).
Resetデフォルト値にリセットします