I recently implemented a custom gizmo to my custom editor mode UInteractiveTool “SelectTool” so that I can use it to move splines. (Code pertaining to the gizmo pasted at the bottom.)
However, when I specify using my tool property “GizmoElements” for the gizmo to have either rotation or scale elements, they do not appear. Translate gizmo elements (axis or planes) appear and function fine.
Update: I have discovered that depending on which editor viewport gizmo I select, the corresponding elements will appear in my tool (i.e scale lets me see scale axis or planes, rotate give the rotate gizmos and translate gives the translation gizmos.) so it seems like somewhere in the engine, all the gizmos exist, but are just being set to visible or hidden based on the 3d viewport tool selection(???)
This likely caused the behavior described below, where enabling the trs gizmo in the editor settings allowed more elements to be seen (since the TRS gizmo was then set to selected by default, and contained the translate, rotate and scale uniform gizmos.)
(Photo of FullTranslateRotateScale selected but only transform appearing and functioning.)
Now, (Oddly) if I go into the editor preferences and enable the combined translate/rotate widget in the viewport settings, the Rotate All Axis and Scale Uniform gizmos will start to appear, however the Scale plane and Scale Axis elements if selected using the property will still be invisible. (See Below Picture)
How I can get all of the TransformGizmoSubElements to appear? Including the Scale Axis elements?
#Includes at the bottom.
UCLASS(Transient)
class RVTROADTOOL_API USelectToolProperties : public UInteractiveToolPropertySet
{
GENERATED_BODY()
public:
USelectToolProperties();
// Selection settings.
UPROPERTY(EditAnywhere, Category = "Selection")
TArray<FSnapResult>SelectedActors;
// How I set my gizmo elements.
UPROPERTY(EditAnywhere, Category = "Selection")
ETransformGizmoSubElements GizmoElements = ETransformGizmoSubElements::TranslateAllAxes;
};
//called whenever the tool is selected
void USelectTool::Setup()
{
UInteractiveTool::Setup();
// this line is supposed to register all of the gizmos with the manager so they can be made.
UCombinedTransformGizmoContextObject* TransformGizmoContextObject = NewObject<UCombinedTransformGizmoContextObject>(this);
TransformGizmoContextObject->RegisterGizmosWithManager(GetToolManager());
}
// Every time the selection is changed, the gizmo is destroyed then this is used to reinitialize it.
void USelectTool::CreateTransformGizmo(FTransform InTransform)
{
UE_LOG(LogTemp, Error, TEXT("Attempting gizmo"));
// Initialize the gizmo's position in the editor
//FTransform InitialTransform = FTransform(Position); // Set an initial location
// Create a transform proxy to manage the gizmo's transform
TransformProxy = NewObject<UTransformProxy>(this);
TransformProxy->SetTransform(InTransform);
GizmoTransform = InTransform;
TransformProxy->OnEndTransformEdit.AddUObject(this, &USelectTool::OnEditTransformEnded);
if (TransformProxy->OnEndTransformEdit.IsBound())
{
UE_LOG(LogTemp, Error, TEXT("Successfully bound OnEndTransformEdit event"));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to bind OnEndTransformEdit event"));
}
TransformGizmo = UE::TransformGizmoUtil::CreateCustomRepositionableTransformGizmo(GetToolManager(), Properties->GizmoElements, this);
TransformGizmo->SetActiveTarget(TransformProxy);
TransformGizmo->SetVisibility(true);
}
// SelectTool.h headers
#include "CoreMinimal.h"
#include "InteractiveToolBuilder.h"
#include "BaseTools/ClickDragTool.h"
#include "BaseBehaviors/MouseHoverBehavior.h"
#include "InteractiveTool.h"
#include "BaseGizmos/GizmoComponents.h"
#include "RoadManager.h"
#include "RoadGizmo.h"
#include "SelectTool.generated.h"
class UTransformProxy;
class UCombinedTransformGizmo;
// SelectTool.cpp headers
#include "Tools/SelectTool.h"
#include "InteractiveToolManager.h"
#include "ToolBuilderUtil.h"
#include "BaseBehaviors/ClickDragBehavior.h"
#include "BaseGizmos/TransformGizmoUtil.h"
#include "CollisionQueryParams.h"
#include "Engine/World.h"
#include "EngineUtils.h"
#include "SceneManagement.h"