{#
    Spawn a Utility widget BP as a tab in unreal.
    'widget_path' must be an asset path (not a _C class path).
#}
import unreal

from upyre_json_pipe import json_pipe

EditorUtilitySubsystem = unreal.get_editor_subsystem(unreal.EditorUtilitySubsystem)
widget = unreal.EditorAssetLibrary.load_asset("{{ widget_path }}")
w, wid = EditorUtilitySubsystem.spawn_and_register_tab_and_get_id(widget)

json_pipe.write("Widget", str(w.get_full_name()).strip())
json_pipe.write("WidgetID", str(wid).strip())
