Passer au contenu principal
Version: latest - a1.172.0 ⚖️

🧭 Gizmo

Un outil pour transformer des objets pendant l'exécution

👪Inheritance
This class shares methods and events from Base Entity, Base Actor.

🎒 Exemples​

-- Disable input and enable mouse cursor
Input.SetInputEnabled(false)
Input.SetMouseEnabled(true)

-- Spawn a mesh to interact with
local my_entity = StaticMesh(Vector(0, 0, 100), Rotator(), "nanos-world::SM_Cube")

-- Spawn the gizmo
local my_gizmo = Gizmo()

-- Activate the gizmo, at the location of the mesh
my_gizmo:Activate(my_entity:GetLocation(), my_entity:GetRotation(), my_entity:GetScale())

-- Subscribes on Gizmo updates
my_gizmo:Subscribe("Transform", function(self, location, rotation, scale)
my_entity:TranslateTo(location, 0.02)
my_entity:RotateTo(rotation, 0.02)
my_entity:SetScale(scale)
end)

-- When Mouse click, trigger Gizmo inputs
Input.Subscribe("MouseDown", function(key)
if (key == "LeftMouseButton") then
my_gizmo:PressPointer()
end
end)

-- When Mouse release, trigger Gizmo inputs
Input.Subscribe("MouseUp", function (key, b, c)
if (key == "LeftMouseButton") then
my_gizmo:ReleasePointer()
end
end)

🛠 Constructeurs​

Default Constructor​

No description provided

local my_gizmo = Gizmo()

This constructor doesn't have parameters.

🗿 Static Functions​

This class doesn't have own static functions.

Inherited static functions

🦠 Fonctions​

ActivateEnables the interaction, placing the Gizmo at the given transform
DeactivateDisable the interaction
IsInteracting: booleanReturns if it's currently interacting
PressPointerTriggers the press pointer event on it
ReleasePointerTriggers the release pointer event on it
SetAlignSpaceSets whether the Gizmo is aligned to the local or the world space
SetSnapSettingsSets the snapping grid sizes, 0 to disable snapping
SetTransformModeSets whether the Gizmo translates, rotates or scales

ActivateModerate​

Enables the interaction, placing the Gizmo at the given transform

my_gizmo:Activate(location, rotation, scale)
Paramètres
NameTypeDescription
locationVectorWorld location of the Gizmo
rotationRotatorWorld rotation of the Gizmo
scaleVectorScale of the Gizmo

DeactivateModerate​

Disable the interaction

my_gizmo:Deactivate()

IsInteractingModerate​

Returns if it's currently interacting

local is_interacting = my_gizmo:IsInteracting()
Returns
TypeDescription
booleanWhether it's currently interacting

PressPointerModerate​

Triggers the press pointer event on it

my_gizmo:PressPointer()

ReleasePointerModerate​

Triggers the release pointer event on it

my_gizmo:ReleasePointer()

SetAlignSpaceModerate​

Sets whether the Gizmo is aligned to the local or the world space

my_gizmo:SetAlignSpace(align_space)
Paramètres
NameTypeDescription
align_spaceGizmoAlignSpaceThe align space

SetSnapSettingsModerate​

Sets the snapping grid sizes, 0 to disable snapping

my_gizmo:SetSnapSettings(location_grid_size, rotation_grid_size, scale_grid_size)
Paramètres
NameTypeDescription
location_grid_sizefloatTranslation snap size, in units
rotation_grid_sizefloatRotation snap size, in degrees
scale_grid_sizefloatScale snap size

SetTransformModeModerate​

Sets whether the Gizmo translates, rotates or scales

my_gizmo:SetTransformMode(transform_mode, combine_translate_rotate)
Paramètres
NameTypeDescription
transform_modeGizmoTransformModeThe transform mode
combine_translate_rotatebooleanWhether to show the translation and rotation handles together

🚀 Events​

TransformDéclenché quand la transformation du Gizmo est mise à jour

Transform​

Déclenché quand la transformation du Gizmo est mise à jour

Gizmo.Subscribe("Transform", function(self, location, rotation, scale)
-- Transform was called
end)
Arguments
NameTypeDescription
selfGizmoThe Gizmo itself
locationVectorNew Gizmo location
rotationRotatorNew Gizmo rotation
scaleVectorNew Gizmo scale