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);
}
}