Hi, I am making some animation tools and I’d like to add some Control Rig specific functionality.
I am unsure as to how to access parts of the rig.
My questions:
- How to change the current displayed ControlRig? Currently the only way I’ve found is to find the other rig in the sequencer and click it there
- How to query a list of ControlRig compatible rigs in the scene?
- How to check if a specific SkeletalMeshActor is a control rig?
- How to query the selected controls?
- How to query all available controls in a control rig?
I’m already looking through the plugin code, but as I’m still new to unreal it’s slow progress.
Thank you
I think I have this figured out, the methods are there on the animation mode, but not exposed as public. I can expose these for use. Once I’ve got what I need I’ll post the code as a solution
Ok so this may not be the most optimal way of working with control rig, but hopefully it helps someone else.
It looks like ControlRig currently only supports one rig active at a time, but hopefully they fix that in the future.
Note you will need to move the controlRigEditMode.h to the public folder, everything else is already accessible.
// Get current ControlRig
FControlRigEditMode* ControlRigEditMode = static_cast<FControlRigEditMode*>(GLevelEditorModeTools().GetActiveMode("EditMode.ControlRig"));
if ( ControlRigEditMode ) {
UControlRig* ControlRig = ControlRigEditMode->GetControlRig( true );
}
// Get a list of loaded control rigs
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(FName("AssetRegistry"));
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
TArray<FAssetData> Sequences;
AssetRegistry.GetAssetsByClass(ULevelSequence::StaticClass()->GetFName(), Sequences);
for (FAssetData SequenceAsset : Sequences) {
// Get LevelSequenceEditor
ULevelSequence* LevelSequence = Cast<ULevelSequence>(SequenceAsset.GetAsset());
if ( LevelSequence ) {
const TArray<FMovieSceneBinding>& Bindings = LevelSequence->MovieScene->GetBindings();
for (const FMovieSceneBinding& Binding : Bindings) {
UMovieSceneControlRigParameterTrack* Track = Cast<UMovieSceneControlRigParameterTrack>(
LevelSequence->MovieScene->FindTrack(UMovieSceneControlRigParameterTrack::StaticClass(), Binding.GetObjectGuid(), NAME_None));
if (Track && Track->GetControlRig()) {
UE_LOG(LogTemp, Warning, TEXT("Found Rig: %s"), *Track->GetControlRig()->GetFullName());
}
}
}
}
// Get Selected Controls
FControlRigEditMode* ControlRigEditMode = static_cast<FControlRigEditMode*>(GLevelEditorModeTools().GetActiveMode("EditMode.ControlRig"));
if ( ControlRigEditMode ) {
UControlRig* ControlRig = ControlRigEditMode->GetControlRig( true );
if ( ControlRig ) {
TArray<FName> Selection = ControlRig->CurrentControlSelection();
TArray<FString> Strings;
for ( FName Name : Selection )
Strings.Add(Name.ToString());
FString Msg = FString::Join(Strings, TEXT(", "));
UE_LOG(LogTemp, Warning, TEXT("Selected: %s"), *Msg);
}
}
// Get available controls
FControlRigEditMode* ControlRigEditMode = static_cast<FControlRigEditMode*>(GLevelEditorModeTools().GetActiveMode("EditMode.ControlRig"));
if ( ControlRigEditMode ) {
UControlRig* ControlRig = ControlRigEditMode->GetControlRig( true );
if ( ControlRig ) {
TArray<FString> Strings;
for (const FRigControl& Control : ControlRig->GetControlHierarchy()) {
Strings.Add(Control.GetDisplayName().ToString());
}
FString Msg = FString::Join(Strings, TEXT("\n"));
UE_LOG(LogTemp, Warning, TEXT("All Controls: %s"), *Msg);
}
}
1 Like