Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MajorTomAW/edc44097312fb6ac972e171cfc417423 to your computer and use it in GitHub Desktop.

Select an option

Save MajorTomAW/edc44097312fb6ac972e171cfc417423 to your computer and use it in GitHub Desktop.
#include "ScriptedAction_OverrideGamepadName.h"
#include "CommonInputBaseTypes.h"
#include "EditorUtilityLibrary.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(ScriptedAction_OverrideGamepadName)
UScriptedAction_OverrideGamepadName::UScriptedAction_OverrideGamepadName()
{
bIsActionForBlueprints = true;
SupportedClasses.Add(UCommonInputBaseControllerData::StaticClass());
}
void UScriptedAction_OverrideGamepadName::OverrideGamepadName(FName NewGamepadName)
{
TArray<UObject*> SelectedObjects = UEditorUtilityLibrary::GetSelectedAssets();
for (UObject* SelectedObject : SelectedObjects)
{
if (const UBlueprint* Blueprint = Cast<UBlueprint>(SelectedObject))
{
if (UCommonInputBaseControllerData* CDO =
Blueprint->GeneratedClass->GetDefaultObject<UCommonInputBaseControllerData>())
{
CDO->GamepadName = NewGamepadName;
CDO->PostEditChange();
CDO->MarkPackageDirty();
}
}
}
}
#pragma once
#include "AssetActionUtility.h"
#include "ScriptedAction_OverrideGamepadName.generated.h"
UCLASS()
class UScriptedAction_OverrideGamepadName : public UAssetActionUtility
{
GENERATED_BODY()
public:
UScriptedAction_OverrideGamepadName();
public:
UFUNCTION(BlueprintCallable, Category=CommonInput, CallInEditor)
void OverrideGamepadName(FName NewGamepadName);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment