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.
Checking the stable version of the documentation...
EditorNode3DGizmo
繼承: Node3DGizmo < RefCounted < Object
Gizmo for editing Node3D objects.
說明
Gizmo that is used for providing custom visualization and editing (handles and subgizmos) for Node3D objects. Can be overridden to create custom gizmos, but for simple gizmos creating an EditorNode3DGizmoPlugin is usually recommended.
方法
void |
_begin_handle_action(id: int, secondary: bool) virtual |
void |
_commit_handle(id: int, secondary: bool, restore: Variant, cancel: bool) virtual |
void |
_commit_subgizmos(ids: PackedInt32Array, restores: Array[Transform3D], cancel: bool) virtual |
_get_handle_name(id: int, secondary: bool) virtual const |
|
_get_handle_value(id: int, secondary: bool) virtual const |
|
_get_subgizmo_transform(id: int) virtual const |
|
_is_handle_highlighted(id: int, secondary: bool) virtual const |
|
void |
_redraw() virtual |
void |
_set_handle(id: int, secondary: bool, camera: Camera3D, point: Vector2) virtual |
void |
_set_subgizmo_transform(id: int, transform: Transform3D) virtual |
_subgizmos_intersect_frustum(camera: Camera3D, frustum: Array[Plane]) virtual const |
|
_subgizmos_intersect_ray(camera: Camera3D, point: Vector2) virtual const |
|
void |
add_collision_segments(segments: PackedVector3Array) |
void |
add_collision_triangles(triangles: TriangleMesh) |
void |
add_handles(handles: PackedVector3Array, material: Material, ids: PackedInt32Array, billboard: bool = false, secondary: bool = false) |
void |
add_lines(lines: PackedVector3Array, material: Material, billboard: bool = false, modulate: Color = Color(1, 1, 1, 1)) |
void |
add_mesh(mesh: Mesh, material: Material = null, transform: Transform3D = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), skeleton: SkinReference = null) |
void |
add_unscaled_billboard(material: Material, default_scale: float = 1, modulate: Color = Color(1, 1, 1, 1)) |
void |
clear() |
get_node_3d() const |
|
get_plugin() const |
|
get_subgizmo_selection() const |
|
is_subgizmo_selected(id: int) const |
|
void |
set_hidden(hidden: bool) |
void |
set_node_3d(node: Node) |
方法說明
void _begin_handle_action(id: int, secondary: bool) virtual 🔗
There is currently no description for this method. Please help us by contributing one!
void _commit_handle(id: int, secondary: bool, restore: Variant, cancel: bool) virtual 🔗
覆蓋該方法,以提交一個正在編輯的控柄(控柄必須是之前通過 add_handles() 新增的)。這通常意味著為該修改建立一個 UndoRedo 動作,將目前控柄值用作“做”,並將 restore 參數用作“撤銷”。
如果 cancel 參數為 true,則應直接設定 restore 值,而不需要任何 UndoRedo 動作。
當提交的控柄為次要控柄時,secondary 參數為 true(有關更多信息,請參閱 add_handles())。
void _commit_subgizmos(ids: PackedInt32Array, restores: Array[Transform3D], cancel: bool) virtual 🔗
覆蓋該方法,以提交一組正在編輯的子小工具(參見 _subgizmos_intersect_ray() 和 _subgizmos_intersect_frustum())。這通常意味著為該更改建立一個 UndoRedo 動作,將目前變換用作“做”,並將 restores 變換用作“撤銷”。
如果 cancel 參數為 true,則restores 變換應被直接設定 ,而無需任何 UndoRedo 動作。
String _get_handle_name(id: int, secondary: bool) virtual const 🔗
覆蓋該方法,以返回編輯的控柄的名稱(控柄必須先前通過 add_handles() 添加的)。可以命名控柄以供使用者在編輯時引用。
當請求的控柄是次要控柄時,secondary 參數為 true(有關更多信息,請參閱 add_handles())。
Variant _get_handle_value(id: int, secondary: bool) virtual const 🔗
覆蓋該方法,以返回一個控柄的目前值。該值將在編輯開始時被請求,並用作 _commit_handle() 中的 restore 參數。
當請求的控柄是次要控柄時,secondary 參數為 true(有關更多信息,請參閱 add_handles())。
Transform3D _get_subgizmo_transform(id: int) virtual const 🔗
覆蓋該方法,以返回子小工具的目前變換。該變換將在編輯開始時被請求,並用作 _commit_subgizmos() 中的 restore 參數。
bool _is_handle_highlighted(id: int, secondary: bool) virtual const 🔗
覆蓋該方法,只要給定的控柄應該在編輯器中被高亮顯示時就返回 true。
當請求的控柄是次要控柄時,secondary 參數為 true(有關更多信息,請參閱 add_handles())。
void _redraw() virtual 🔗
覆蓋該方法,每當請求小工具更新時將新增所有小工具元素。通常在該方法的開頭呼叫 clear(),然後根據節點的屬性新增可視元素。
void _set_handle(id: int, secondary: bool, camera: Camera3D, point: Vector2) virtual 🔗
覆蓋該方法,當使用者拖動小工具控柄(之前使用 add_handles() 新增的)時更新節點屬性。提供的 point 是螢幕座標中的滑鼠位置, camera 可用於將其轉換為射線投射。
當編輯的控柄是次要控柄時,secondary 參數為 true(有關更多信息,請參閱 add_handles())。
void _set_subgizmo_transform(id: int, transform: Transform3D) virtual 🔗
Override this method to update the node properties during subgizmo editing (see _subgizmos_intersect_ray() and _subgizmos_intersect_frustum()). The transform is given in the Node3D's local coordinate system.
PackedInt32Array _subgizmos_intersect_frustum(camera: Camera3D, frustum: Array[Plane]) virtual const 🔗
Override this method to allow selecting subgizmos using mouse drag box selection. Given a camera and a frustum, this method should return which subgizmos are contained within the frustum. The frustum 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, which can have any non-negative value and will be used in other virtual methods like _get_subgizmo_transform() or _commit_subgizmos().
int _subgizmos_intersect_ray(camera: Camera3D, point: Vector2) virtual const 🔗
覆蓋該方法,以允許使用滑鼠點擊選擇子小工具。給定螢幕座標中的 camera 和 point 時,該方法應返回應選擇哪個子小工具。返回值應該是一個唯一的子小工具識別字,它可以有任何非負值,並將用於其他虛方法,如 _get_subgizmo_transform() 或 _commit_subgizmos()。
void add_collision_segments(segments: PackedVector3Array) 🔗
將指定的 segments 新增到小工具的碰撞形狀以進行拾取。在 _redraw() 期間呼叫該方法。
void add_collision_triangles(triangles: TriangleMesh) 🔗
將碰撞三角形新增到小工具以進行拾取。TriangleMesh 也可以從常規 Mesh 生成。在 _redraw() 期間呼叫該方法。
void add_handles(handles: PackedVector3Array, material: Material, ids: PackedInt32Array, billboard: bool = false, secondary: bool = false) 🔗
Adds a list of handles (points) which can be used to edit the properties of the gizmo's Node3D. The ids argument can be used to specify a custom identifier for each handle, if an empty array is passed, the ids will be assigned automatically from the handles argument order.
The secondary argument marks the added handles as secondary, meaning they will normally have lower selection priority than regular handles. When the user is holding the shift key secondary handles will switch to have higher priority than regular handles. This change in priority can be used to place multiple handles at the same point while still giving the user control on their selection.
There are virtual methods which will be called upon editing of these handles. Call this method during _redraw().
void add_lines(lines: PackedVector3Array, material: Material, billboard: bool = false, modulate: Color = Color(1, 1, 1, 1)) 🔗
為小工具新增使用給定材質的線段(一對對點的集合)。線段將用於展示和選擇。請在 _redraw() 期間呼叫此方法。
void add_mesh(mesh: Mesh, material: Material = null, transform: Transform3D = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), skeleton: SkinReference = null) 🔗
為小工具新增網格,可以指定材質 material、本地變換 transform 和骨架 skeleton。請在 _redraw() 期間呼叫此方法。
void add_unscaled_billboard(material: Material, default_scale: float = 1, modulate: Color = Color(1, 1, 1, 1)) 🔗
新增未縮放的公告板,將用於展示和選擇。請在 _redraw() 期間呼叫此方法。
void clear() 🔗
移除小工具中的一切,包括網格、碰撞和控柄。
返回與這個小工具關聯的 Node3D 節點。
EditorNode3DGizmoPlugin get_plugin() const 🔗
返回擁有該小工具的 EditorNode3DGizmoPlugin。可以在使用 EditorNode3DGizmoPlugin.get_material() 獲取材質時使用。
PackedInt32Array get_subgizmo_selection() const 🔗
返回目前選定的子小工具的列表。可用於在 _redraw() 期間高亮顯示所選元素。
bool is_subgizmo_selected(id: int) const 🔗
如果給定的子小工具是目前所選定的,則返回 true。可用於在 _redraw() 期間高亮顯示所選元素。
設定該小工具的隱藏狀態。如果為 true,則該小工具將被隱藏。如果為 false 則會顯示。