Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

EditorNode3DGizmoPlugin

繼承: Resource < RefCounted < Object

編輯器用來定義 Node3D 小工具型別的類。

說明

EditorNode3DGizmoPlugin 允許定義一種新的小工具型別。定義主要有兩種方法:比較簡單的小工具可以擴充 EditorNode3DGizmoPlugin,否則可以建立新的 EditorNode3DGizmo 型別。有關詳細資訊,請參閱文件中的教學。

要使用 EditorNode3DGizmoPlugin,請先使用 EditorPlugin.add_node_3d_gizmo_plugin() 方法註冊它。

教學

方法

void

_begin_handle_action(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual

bool

_can_be_hidden() virtual const

bool

_can_commit_handle_on_click() virtual const

void

_commit_handle(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool, restore: Variant, cancel: bool) virtual

void

_commit_subgizmos(gizmo: EditorNode3DGizmo, ids: PackedInt32Array, restores: Array[Transform3D], cancel: bool) virtual

EditorNode3DGizmo

_create_gizmo(for_node_3d: Node3D) virtual const

String

_get_gizmo_name() virtual const

String

_get_handle_name(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual const

Variant

_get_handle_value(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual const

int

_get_priority() virtual const

Transform3D

_get_subgizmo_transform(gizmo: EditorNode3DGizmo, subgizmo_id: int) virtual const

bool

_has_gizmo(for_node_3d: Node3D) virtual const

bool

_is_handle_highlighted(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual const

bool

_is_selectable_when_hidden() virtual const

void

_redraw(gizmo: EditorNode3DGizmo) virtual

void

_set_handle(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool, camera: Camera3D, screen_pos: Vector2) virtual

void

_set_subgizmo_transform(gizmo: EditorNode3DGizmo, subgizmo_id: int, transform: Transform3D) virtual

PackedInt32Array

_subgizmos_intersect_frustum(gizmo: EditorNode3DGizmo, camera: Camera3D, frustum_planes: Array[Plane]) virtual const

int

_subgizmos_intersect_ray(gizmo: EditorNode3DGizmo, camera: Camera3D, screen_pos: Vector2) virtual const

void

add_material(name: String, material: StandardMaterial3D)

void

create_handle_material(name: String, billboard: bool = false, texture: Texture2D = null)

void

create_icon_material(name: String, texture: Texture2D, on_top: bool = false, color: Color = Color(1, 1, 1, 1))

void

create_material(name: String, color: Color, billboard: bool = false, on_top: bool = false, use_vertex_color: bool = false)

StandardMaterial3D

get_material(name: String, gizmo: EditorNode3DGizmo = null)


方法說明

void _begin_handle_action(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual 🔗

There is currently no description for this method. Please help us by contributing one!


bool _can_be_hidden() virtual const 🔗

覆蓋該方法,以定義是否可以隱藏該外掛程式處理的小工具。如果未被覆蓋,則返回 true


bool _can_commit_handle_on_click() virtual const 🔗

Override this method to define whether the gizmos should commit when the final handle position is the same as the initial one. Returns false if not overridden.


void _commit_handle(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool, restore: Variant, cancel: bool) virtual 🔗

覆蓋該方法,以提交正在編輯的控柄(控柄必須是先前在 _redraw() 期間通過 EditorNode3DGizmo.add_handles() 新增的)。這通常意味著為該更改建立一個 UndoRedo 動作,將目前控柄值用作“做”,並將 restore 參數用作“撤銷”。

如果 cancel 參數為 true,則 restore 值應被直接設置,無需任何 UndoRedo 動作。

當提交的控柄為次要控柄時,secondary 參數為 true(有關更多信息,請參閱 EditorNode3DGizmo.add_handles())。

為該外掛程式的活動小工具而呼叫。


void _commit_subgizmos(gizmo: EditorNode3DGizmo, ids: PackedInt32Array, restores: Array[Transform3D], cancel: bool) virtual 🔗

覆蓋該方法,以提交一組正在編輯的子小工具(參見 _subgizmos_intersect_ray()_subgizmos_intersect_frustum())。這通常意味著為該更改建立一個 UndoRedo 動作,將目前變換用作“做”,並將 restores 變換用作“撤銷”。

如果 cancel 參數為 true,則 restores 變換應被直接設定,無需任何 UndoRedo 動作。對於所有子小工具方法,變換是在與小工具的 Node3D 相關的局部空間中給出的。為該外掛程式的活動小工具而呼叫。


EditorNode3DGizmo _create_gizmo(for_node_3d: Node3D) virtual const 🔗

Override this method to return a custom EditorNode3DGizmo for the 3D nodes of your choice, return null for the rest of nodes. See also _has_gizmo().


String _get_gizmo_name() virtual const 🔗

覆蓋該方法,以提供將出現在小工具可見性功能表中的名稱。


String _get_handle_name(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual const 🔗

覆蓋該方法,以提供小工具的控柄名稱。當請求的控柄是次要控柄時,secondary 參數為 true(有關更多資訊,請參閱 EditorNode3DGizmo.add_handles())。為該外掛程式的活動小工具而呼叫。


Variant _get_handle_value(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual const 🔗

覆蓋該方法,以返回一個控柄的目前值。該值將在編輯開始時被請求,並用作 _commit_handle() 中的 restore 參數。

當請求的控柄是次要控柄時,secondary 參數為 true(有關更多信息,請參閱 EditorNode3DGizmo.add_handles())。

為該外掛程式的活動小工具而呼叫。


int _get_priority() virtual const 🔗

覆蓋該方法,以設定該小工具的優先順序。具有更高優先順序的小工具,將在處理控柄或子小工具選擇等輸入時具有優先權。

所有內建編輯器小工具都會返回 -1 的優先順序。如果未被覆蓋,該方法將返回 0,這意味著自訂小工具將自動獲得比內建小工具更高的優先順序。


Transform3D _get_subgizmo_transform(gizmo: EditorNode3DGizmo, subgizmo_id: int) virtual const 🔗

覆蓋該方法,以返回子小工具的目前變換。對於所有子小工具方法,變換應該在相對於小工具的 Node3D 的局部空間中。此變換將在編輯開始時被請求,並在 _commit_subgizmos() 中的 restore 參數中使用。為該外掛程式的活動小工具而呼叫。


bool _has_gizmo(for_node_3d: Node3D) virtual const 🔗

覆蓋該方法,以定義哪些 Node3D 節點具有來自該外掛程式的小工具。每當將 Node3D 節點新增到場景時,該方法都會被呼叫,如果它返回 true,則該節點將被分配一個通用的 EditorNode3DGizmo,並被新增到該外掛程式的活動小工具列表中。


bool _is_handle_highlighted(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool) virtual const 🔗

覆蓋該方法,以在編輯器中高亮顯示給定控柄時返回 true。當請求的控柄是次要控柄時,secondary 參數為 true(有關更多資訊,請參閱 EditorNode3DGizmo.add_handles())。為該外掛程式的活動小工具而呼叫。


bool _is_selectable_when_hidden() virtual const 🔗

覆蓋該方法,以定義具有該小工具的 Node3D 是否應該是可選的,即使該小工具被隱藏。


void _redraw(gizmo: EditorNode3DGizmo) virtual 🔗

覆蓋該方法,以在每當請求小工具更新時新增所有小工具元素。通常在該方法的開頭調用 EditorNode3DGizmo.clear(),然後根據節點的屬性新增可視元素。


void _set_handle(gizmo: EditorNode3DGizmo, handle_id: int, secondary: bool, camera: Camera3D, screen_pos: Vector2) virtual 🔗

覆蓋該方法,以在使用者拖動小工具控柄(控柄是之前使用 EditorNode3DGizmo.add_handles() 新增的)時更新節點的屬性。提供的 screen_pos 是螢幕座標中的滑鼠位置, camera 可用於將其轉換為射線投射。

當編輯的控柄是次要控柄時,secondary 參數為 true(有關更多信息,請參閱 EditorNode3DGizmo.add_handles())。

為該外掛程式的活動小工具而呼叫。


void _set_subgizmo_transform(gizmo: EditorNode3DGizmo, subgizmo_id: int, transform: Transform3D) virtual 🔗

覆蓋該方法,以在子小工具編輯期間更新節點屬性(參見 _subgizmos_intersect_ray()_subgizmos_intersect_frustum())。transform 在 Node3D 的局部坐標系中給出。為該外掛程式的活動小工具而呼叫。


PackedInt32Array _subgizmos_intersect_frustum(gizmo: EditorNode3DGizmo, camera: Camera3D, frustum_planes: Array[Plane]) virtual const 🔗

Override this method to allow selecting subgizmos using mouse drag box selection. Given a camera and frustum_planes, this method should return which subgizmos are contained within the frustums. The frustum_planes argument consists of an array with all the Planes that make up the selection frustum. The returned value should contain a list of unique subgizmo identifiers, these identifiers can have any non-negative value and will be used in other virtual methods like _get_subgizmo_transform() or _commit_subgizmos(). Called for this plugin's active gizmos.


int _subgizmos_intersect_ray(gizmo: EditorNode3DGizmo, camera: Camera3D, screen_pos: Vector2) virtual const 🔗

覆蓋該方法,以允許使用滑鼠點擊選擇子小工具。給定螢幕座標中的 camerascreen_pos 時,該方法應返回應選擇哪個子小工具。返回值應該是一個唯一的子小工具識別字,它可以有任何非負值,並將用於其他虛方法,如 _get_subgizmo_transform()_commit_subgizmos()。為該外掛程式的活動小工具而呼叫。


void add_material(name: String, material: StandardMaterial3D) 🔗

將新材質新增到該外掛程式的內部材質列表中。然後可以使用 get_material() 存取它。不應被重寫。


void create_handle_material(name: String, billboard: bool = false, texture: Texture2D = null) 🔗

建立具有變體(選定的和/或可編輯的)的控柄材質,並將它們新增到內部材質列表中。然後可以使用 get_material() 存取它們,並在 EditorNode3DGizmo.add_handles() 中使用它們。不應被重寫。

可以選擇提供一個要使用的紋理代替預設圖示。


void create_icon_material(name: String, texture: Texture2D, on_top: bool = false, color: Color = Color(1, 1, 1, 1)) 🔗

建立具有變體(選定的和/或可編輯的)的圖示材質,並將它們新增到內部材質列表中。然後可以使用 get_material() 存取它們,並在 EditorNode3DGizmo.add_unscaled_billboard() 中使用它們。不應被重寫。


void create_material(name: String, color: Color, billboard: bool = false, on_top: bool = false, use_vertex_color: bool = false) 🔗

建立具有變體(選定的和/或可編輯的)的未著色材質,並將它們新增到內部材質列表中。然後可以使用 get_material() 存取它們,並在 EditorNode3DGizmo.add_mesh()EditorNode3DGizmo.add_lines() 中使用。不應被重寫。


StandardMaterial3D get_material(name: String, gizmo: EditorNode3DGizmo = null) 🔗

從內部材質列表中獲取材質。如果提供了一個 EditorNode3DGizmo,它將嘗試獲取相應的變體(選定的和/或可編輯的)。