Implement interaction prompt
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import unreal
|
||||
|
||||
|
||||
def load(path):
|
||||
asset = unreal.EditorAssetLibrary.load_asset(path)
|
||||
if not asset:
|
||||
raise RuntimeError(f"Could not load {path}")
|
||||
return asset
|
||||
|
||||
|
||||
def main():
|
||||
game_mode_bp = load("/Game/ThirdPerson/Blueprints/BP_ThirdPersonGameMode")
|
||||
game_mode_cdo = unreal.get_default_object(game_mode_bp.generated_class())
|
||||
hud_class = unreal.load_class(None, "/Script/AgrarianGame.AgrarianDebugHUD")
|
||||
if not hud_class:
|
||||
raise RuntimeError("Could not load /Script/AgrarianGame.AgrarianDebugHUD")
|
||||
|
||||
game_mode_cdo.set_editor_property("hud_class", hud_class)
|
||||
unreal.EditorAssetLibrary.save_loaded_asset(game_mode_bp)
|
||||
|
||||
unreal.log("Agrarian interaction prompt setup complete.")
|
||||
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,42 @@
|
||||
import unreal
|
||||
|
||||
|
||||
def load(path):
|
||||
asset = unreal.EditorAssetLibrary.load_asset(path)
|
||||
if not asset:
|
||||
raise RuntimeError(f"Could not load {path}")
|
||||
return asset
|
||||
|
||||
|
||||
def main():
|
||||
game_mode_bp = load("/Game/ThirdPerson/Blueprints/BP_ThirdPersonGameMode")
|
||||
game_mode_cdo = unreal.get_default_object(game_mode_bp.generated_class())
|
||||
expected_hud_class = unreal.load_class(None, "/Script/AgrarianGame.AgrarianDebugHUD")
|
||||
character_class = unreal.load_class(None, "/Script/AgrarianGame.AgrarianGameCharacter")
|
||||
hud_cdo = unreal.get_default_object(expected_hud_class) if expected_hud_class else None
|
||||
character_cdo = unreal.get_default_object(character_class) if character_class else None
|
||||
|
||||
missing = []
|
||||
if not expected_hud_class:
|
||||
missing.append("could not load AgrarianDebugHUD class")
|
||||
elif game_mode_cdo.get_editor_property("hud_class") != expected_hud_class:
|
||||
missing.append("BP_ThirdPersonGameMode HUD class is not AgrarianDebugHUD")
|
||||
elif hud_cdo:
|
||||
if not bool(hud_cdo.get_editor_property("bShowInteractionPrompt")):
|
||||
missing.append("AgrarianDebugHUD bShowInteractionPrompt is disabled")
|
||||
if float(hud_cdo.get_editor_property("PromptTextScale")) <= 0.0:
|
||||
missing.append("AgrarianDebugHUD PromptTextScale is not positive")
|
||||
|
||||
if not character_class:
|
||||
missing.append("could not load AgrarianGameCharacter class")
|
||||
elif character_cdo:
|
||||
character_cdo.get_editor_property("InteractionPromptText")
|
||||
character_cdo.get_editor_property("FocusedInteractableActor")
|
||||
|
||||
if missing:
|
||||
raise RuntimeError("Interaction prompt verification failed: " + "; ".join(missing))
|
||||
|
||||
unreal.log("Agrarian interaction prompt verification complete.")
|
||||
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user