Subsystem API
UInhyeongOBSSubsystem 是一个 UGameInstanceSubsystem,负责管理 OBS WebSocket 连接并公开 100 余个可在 Blueprint 中调用的方法。它在关卡加载之间保持持久,是控制 OBS 的主要外观接口。
从 C++ 访问:
UInhyeongOBSSubsystem* OBS = GetGameInstance()->GetSubsystem<UInhyeongOBSSubsystem>();
从 Blueprint 访问:Get Game Instance → Get Subsystem (InhyeongOBSSubsystem)。
注意: OBS Component(UInhyeongOBSComponent)几乎镜像了这里所有方法以供单个 Actor 使用,并额外支持场景监视(参见 OBS Component)。未在此处直接公开的处理器级方法可通过 GetClient()->GetXxx() 访问(参见 Handlers API)。
在本页中,BlueprintPure getter(即 GetCached* / Is* / 状态读取函数)标注为 (Pure),其余均为 BlueprintCallable。大多数非 Pure getter 为异步操作:它们向 OBS 发送请求,结果通过委托事件返回(参见 Events)。
连接
| 函数 | 签名 / 参数 | 说明 |
|---|
Connect | (FString Host = "localhost", int32 Port = 4455, FString Password = "", bool bAutoReconnect = true) | 连接并向 OBS WebSocket 服务器进行身份验证。 |
SetAutoReconnect | (bool bAutoReconnect) | 启用/禁用自动重连。 |
Disconnect | () | 关闭连接并清除待处理请求。 |
IsConnected | () → bool | (Pure) 完全连接并完成识别时返回 true。 |
GetConnectionState | () → EOBSConnectionState | (Pure) 当前连接状态(Disconnected/Connecting/Authenticating/Connected)。 |
GetClient | () → UInhyeongOBSWebSocketClient* | (Pure) 直接访问客户端,用于高级用法和处理器穿透。 |
场景集合
| 函数 | 签名 / 参数 | 说明 |
|---|
GetSceneCollectionList | () | 获取场景集合列表。 |
SetCurrentSceneCollection | (FString SceneCollectionName) | 切换当前活动的场景集合。 |
CreateSceneCollection | (FString SceneCollectionName) | 创建新的场景集合。 |
GetCachedSceneCollections | () → TArray<FString> | (Pure) 已缓存的场景集合名称。 |
GetCurrentSceneCollectionName | () → FString | (Pure) 已缓存的当前活动场景集合。 |
配置文件
| 函数 | 签名 / 参数 | 说明 |
|---|
GetProfileList | () | 获取配置文件列表。 |
SetCurrentProfile | (FString ProfileName) | 切换当前活动的配置文件。 |
CreateProfile | (FString ProfileName) | 创建新的配置文件。 |
RemoveProfile | (FString ProfileName) | 删除配置文件。 |
GetCachedProfiles | () → TArray<FString> | (Pure) 已缓存的配置文件名称。 |
GetCurrentProfileName | () → FString | (Pure) 已缓存的当前活动配置文件。 |
视频设置
| 函数 | 签名 / 参数 | 说明 |
|---|
GetVideoSettings | () | 获取当前视频设置。 |
SetVideoSettings | (FOBSVideoSettings Settings) | 设置完整视频设置。 |
SetBaseResolution | (int32 Width, int32 Height) | 设置基础(画布)分辨率。 |
SetOutputResolution | (int32 Width, int32 Height) | 设置缩放后的输出分辨率。 |
SetFPS | (int32 FpsNumerator, int32 FpsDenominator = 1) | 设置输出帧率。 |
GetCachedVideoSettings | () → FOBSVideoSettings | (Pure) 已缓存的视频设置。 |
推流服务设置
| 函数 | 签名 / 参数 | 说明 |
|---|
GetStreamServiceSettings | () | 获取当前推流服务设置。 |
SetStreamServiceSettings | (FOBSStreamServiceSettings Settings) | 设置推流服务设置。 |
SetSimpleRTMPSettings | (FString Server, FString StreamKey) | 配置自定义 RTMP 服务器及推流密钥。 |
GetCachedStreamServiceSettings | () → FOBSStreamServiceSettings | (Pure) 已缓存的推流服务设置。 |
场景
| 函数 | 签名 / 参数 | 说明 |
|---|
GetSceneList | () | 获取场景列表。 |
SetCurrentScene | (FString SceneName) | 切换当前活动的直播场景。 |
GetCurrentSceneName | () → FString | (Pure) 已缓存的当前活动场景名称。 |
GetCachedScenes | () → TArray<FOBSScene> | (Pure) 已缓存的场景列表。 |
场景项目变换
| 函数 | 签名 / 参数 | 说明 |
|---|
GetSceneItemTransform | (FString SceneName, int32 SceneItemId) | 获取场景项目的变换信息。 |
SetSceneItemTransform | (FString SceneName, int32 SceneItemId, FOBSSceneItemTransform Transform) | 设置场景项目的完整变换。 |
SetSceneItemPosition | (FString SceneName, int32 SceneItemId, float X, float Y) | 仅设置位置。 |
SetSceneItemRotation | (FString SceneName, int32 SceneItemId, float Rotation) | 仅设置旋转(度数)。 |
SetSceneItemScale | (FString SceneName, int32 SceneItemId, float ScaleX, float ScaleY) | 仅设置缩放。 |
SetSceneItemCrop | (FString SceneName, int32 SceneItemId, int32 Left, int32 Top, int32 Right, int32 Bottom) | 设置裁剪边距。 |
SetSceneItemBounds | (FString SceneName, int32 SceneItemId, EOBSBoundsType BoundsType, float BoundsWidth, float BoundsHeight, int32 BoundsAlignment = 0) | 设置边界框行为。 |
GetSceneItemId | (FString SceneName, FString SourceName) | 将来源名称解析为对应的场景项目数字 ID。 |
场景项目增删改查
| 函数 | 签名 / 参数 | 说明 |
|---|
CreateSceneItem | (FString SceneName, FString SourceName, bool bEnabled = true) | 将已有来源添加到场景中。 |
RemoveSceneItem | (FString SceneName, int32 SceneItemId) | 从场景中移除项目。 |
DuplicateSceneItem | (FString SceneName, int32 SceneItemId, FString DestinationSceneName = "") | 复制项目(可选择复制到另一场景)。 |
场景项目锁定 / 层级顺序 / 混合模式
| 函数 | 签名 / 参数 | 说明 |
|---|
GetSceneItemLocked | (FString SceneName, int32 SceneItemId) | 获取锁定状态。 |
SetSceneItemLocked | (FString SceneName, int32 SceneItemId, bool bLocked) | 设置锁定状态。 |
GetSceneItemIndex | (FString SceneName, int32 SceneItemId) | 获取层级顺序索引(0 为最底层)。 |
SetSceneItemIndex | (FString SceneName, int32 SceneItemId, int32 ItemIndex) | 设置层级顺序索引(0 为最底层)。 |
GetSceneItemBlendMode | (FString SceneName, int32 SceneItemId) | 获取混合模式。 |
SetSceneItemBlendMode | (FString SceneName, int32 SceneItemId, EOBSBlendMode BlendMode) | 设置混合模式。 |
录制
| 函数 | 签名 / 参数 | 说明 |
|---|
StartRecord | () | 开始录制。 |
StopRecord | () | 停止录制。 |
ToggleRecord | () | 切换录制开/关。 |
PauseRecord | () | 暂停当前录制。 |
ResumeRecord | () | 恢复已暂停的录制。 |
ToggleRecordPause | () | 切换暂停/恢复。 |
GetRecordStatus | () | 获取录制状态。 |
GetRecordDirectory | () | 获取录制目录(触发 OnRecordDirectoryReceived)。 |
SetRecordDirectory | (FString Directory) | 设置录制目录(下次录制时生效)。 |
GetCachedRecordDirectory | () → FString | (Pure) 已缓存的录制目录。 |
SplitRecordFile | () | 将当前录制分割为新文件。 |
CreateRecordChapter | (FString ChapterName = "") | 添加章节标记(仅限 Hybrid MP4,需要 OBS 30.2.0 及以上版本)。 |
推流
| 函数 | 签名 / 参数 | 说明 |
|---|
StartStream | () | 开始推流。 |
StopStream | () | 停止推流。 |
ToggleStream | () | 切换推流开/关。 |
GetStreamStatus | () | 获取推流状态。 |
SendStreamCaption | (FString CaptionText) | 发送 CEA-608 字幕文本(推流必须处于活动状态)。 |
虚拟摄像头
| 函数 | 签名 / 参数 | 说明 |
|---|
StartVirtualCam | () | 启动虚拟摄像头。 |
StopVirtualCam | () | 停止虚拟摄像头。 |
ToggleVirtualCam | () | 切换虚拟摄像头。 |
GetVirtualCamStatus | () | 获取虚拟摄像头状态。 |
IsVirtualCamActive | () → bool | (Pure) 已缓存的虚拟摄像头活动状态。 |
Replay Buffer
| 函数 | 签名 / 参数 | 说明 |
|---|
StartReplayBuffer | () | 启动 Replay Buffer。 |
StopReplayBuffer | () | 停止 Replay Buffer。 |
ToggleReplayBuffer | () | 切换 Replay Buffer。 |
SaveReplayBuffer | () | 将当前 Replay Buffer 内容保存到磁盘。 |
GetReplayBufferStatus | () | 获取 Replay Buffer 状态。 |
IsReplayBufferActive | () → bool | (Pure) 已缓存的 Replay Buffer 活动状态。 |
通用输出
| 函数 | 签名 / 参数 | 说明 |
|---|
GetOutputList | () | 获取所有输出的列表。 |
GetOutputStatus | (FString OutputName) | 获取指定输出的状态。 |
GetOutputSettings | (FString OutputName) | 获取指定输出的设置。 |
SetOutputSettings | (FString OutputName, FString JsonSettings) | 从 JSON 设置输出的配置。 |
StartOutput | (FString OutputName) | 启动指定输出。 |
StopOutput | (FString OutputName) | 停止指定输出。 |
ToggleOutput | (FString OutputName) | 切换指定输出。 |
GetCachedOutputs | () → TArray<FOBSOutput> | (Pure) 已缓存的输出列表。 |
音频
| 函数 | 签名 / 参数 | 说明 |
|---|
GetInputList | (FString InputKind = "") | 获取输入列表,可按输入类型过滤。 |
SetInputMute | (FString InputName, bool bMuted) | 设置输入的静音状态。 |
ToggleInputMute | (FString InputName) | 切换输入的静音状态。 |
SetInputVolume | (FString InputName, float VolumeDb) | 设置输入的音量(dB)。 |
SetVolumeMetersEnabled | (bool bEnable) | 订阅高频 InputVolumeMeters 事件(默认禁用)。 |
SetInputActiveStateEventsEnabled | (bool bEnable) | 订阅 InputActiveStateChanged 事件(默认禁用)。 |
高级音频
| 函数 | 签名 / 参数 | 说明 |
|---|
GetInputAudioBalance | (FString InputName) | 获取立体声平衡(0=左声道,0.5=中,1=右声道)。 |
SetInputAudioBalance | (FString InputName, float Balance) | 设置立体声平衡。 |
GetInputAudioSyncOffset | (FString InputName) | 获取同步偏移(毫秒)。 |
SetInputAudioSyncOffset | (FString InputName, int32 OffsetMs) | 设置同步偏移(-950 至 20000 毫秒)。 |
GetInputAudioMonitorType | (FString InputName) | 获取音频监听类型。 |
SetInputAudioMonitorType | (FString InputName, EOBSMonitorType MonitorType) | 设置音频监听类型。 |
GetInputAudioTracks | (FString InputName) | 获取各音轨的启用状态。 |
SetInputAudioTracks | (FString InputName, FOBSAudioTracks Tracks) | 设置所有音轨的启用状态。 |
SetInputAudioTrack | (FString InputName, int32 TrackNumber, bool bEnabled) | 设置单条音轨(1 至 6)的启用状态。 |
GetSpecialInputs | () | 获取默认桌面音频/麦克风设备。 |
GetCachedSpecialInputs | () → FOBSSpecialInputs | (Pure) 已缓存的特殊输入。 |
麦克风 / 语音活动检测
| 函数 | 签名 / 参数 | 说明 |
|---|
EnableMicActivityDetection | (FString InputName, float ThresholdDb = -40, float AttackSeconds = 0.05, float ReleaseSeconds = 0.5) | 启动带防抖的说话/静默检测(自动启用音量表)。 |
DisableMicActivityDetection | (FString InputName) | 停止对指定输入的检测(保留音量表订阅)。 |
IsMicActive | (FString InputName) → bool | (Pure) 当前带防抖的说话状态(未注册时返回 false)。 |
输入(增删改查)
| 函数 | 签名 / 参数 | 说明 |
|---|
CreateInput | (FString SceneName, FString InputName, FString InputKind, FString InputSettingsJson = "", bool bSceneItemEnabled = true) | 创建新输入并将其添加到场景中。 |
RemoveInput | (FString InputName) | 移除输入(不得处于使用中)。 |
SetInputName | (FString InputName, FString NewInputName) | 重命名输入。 |
GetInputKindList | (bool bUnversioned = false) | 获取可用的输入类型列表。 |
GetCachedInputKinds | () → TArray<FString> | (Pure) 已缓存的输入类型列表。 |
输入设置
| 函数 | 签名 / 参数 | 说明 |
|---|
FetchInputSettings | (FString InputName) | 获取输入的当前设置(触发处理器事件)。 |
SetInputSettings | (FString InputName, FString SettingsJson, bool bOverlay = true) | 从 JSON 设置输入配置。 |
SetTextSourceText | (FString InputName, FString NewText) | 便捷方法:设置文本源的文本内容。 |
SetBrowserSourceUrl | (FString InputName, FString NewUrl) | 便捷方法:设置浏览器源的 URL。 |
SetImageSourceFile | (FString InputName, FString NewFilePath) | 便捷方法:设置图像源的文件路径。 |
SetMediaSourceFile | (FString InputName, FString NewFilePath, bool bLooping = false) | 便捷方法:设置媒体源的文件路径。 |
SetColorSourceColor | (FString InputName, int64 Color) | 便捷方法:设置色源的颜色(ABGR 格式的 int64)。 |
媒体
Subsystem 不直接公开媒体播放操作。播放控制(播放/暂停/停止/重新开始、跳转、状态查询)请通过媒体输入处理器访问:
OBS->GetMediaInputs()->...
有关 UInhyeongOBSMediaInputs 的详细信息,请参见 Handlers API。
工作室模式
| 函数 | 签名 / 参数 | 说明 |
|---|
GetStudioModeEnabled | () | 获取工作室模式启用状态。 |
SetStudioModeEnabled | (bool bEnabled) | 启用/禁用工作室模式。 |
IsStudioModeEnabled | () → bool | (Pure) 已缓存的工作室模式状态。 |
GetCurrentPreviewScene | () | 获取预览场景。 |
SetCurrentPreviewScene | (FString SceneName) | 设置预览场景。 |
TriggerStudioModeTransition | () | 将预览场景推送至直播画面。 |
GetPreviewSceneName | () → FString | (Pure) 已缓存的预览场景名称。 |
转场
| 函数 | 签名 / 参数 | 说明 |
|---|
GetSceneTransitionList | () | 获取转场列表。 |
GetCurrentSceneTransition | () | 获取当前活动的转场。 |
SetCurrentSceneTransition | (FString TransitionName) | 设置当前活动的转场。 |
SetCurrentSceneTransitionDuration | (int32 DurationMs) | 设置转场时长。 |
GetCurrentTransitionName | () → FString | (Pure) 已缓存的当前活动转场名称。 |
GetCurrentTransitionDuration | () → int32 | (Pure) 已缓存的转场时长(毫秒)。 |
IsTransitionActive | () → bool | (Pure) 已缓存的”转场进行中”状态。 |
滤镜
Subsystem 不直接公开滤镜的增删改查操作。来源滤镜管理(创建/移除/重命名/重排序、启用、设置)请通过滤镜处理器访问:
OBS->GetFilters()->...
滤镜事件会在 Subsystem 上重新广播(参见 Events)。有关 UInhyeongOBSFilters 的详细信息,请参见 Handlers API。
截图
Subsystem 不直接公开截图捕获方法。请通过截图处理器访问:
OBS->GetScreenshots()->...
截图结果委托已在 Subsystem 上重新广播(OnScreenshotCaptured / OnScreenshotSaved),但捕获方法位于处理器上。有关 UInhyeongOBSScreenshots 的详细信息,请参见 Handlers API。
游戏事件(引擎 → OBS)
| 函数 | 签名 / 参数 | 说明 |
|---|
EmitGameEvent | (FString EventName, FString PayloadJson, FString Realm = "inhyeongobs") → bool | 向 OBS 触发带命名空间的自定义事件。未连接或载荷不是有效 JSON 时返回 false。 |
EmitGameEventMap | (FString EventName, TMap<FString,FString> Payload, FString Realm = "inhyeongobs") | Map 便捷方法:每个键值对将作为载荷下的 JSON 字符串字段。 |
处理器访问器
这些 BlueprintPure getter 返回客户端所拥有的各功能域处理器。使用它们可访问未直接公开在 Subsystem 上的处理器级方法(参见 Handlers API)。
| 函数 | 返回类型 | 功能域 |
|---|
GetOutputs | UInhyeongOBSOutputs* | 推流、录制、虚拟摄像头、Replay Buffer。 |
GetScenes | UInhyeongOBSScenes* | 场景切换、场景项目。 |
GetAudio | UInhyeongOBSAudio* | 输入列表、音量、静音、音量表。 |
GetInputSettings | UInhyeongOBSInputSettings* | 文本/浏览器/图像/媒体源设置。 |
GetMediaInputs | UInhyeongOBSMediaInputs* | 媒体源播放控制。 |
GetStudioMode | UInhyeongOBSStudioMode* | 预览场景、录像棚转场、T-Bar。 |
GetTransitions | UInhyeongOBSTransitions* | 场景转场、时长、设置。 |
GetFilters | UInhyeongOBSFilters* | 来源滤镜管理。 |
GetScreenshots | UInhyeongOBSScreenshots* | 将截图捕获为 base64 或文件。 |
GetConfig | UInhyeongOBSConfig* | 场景集合、配置文件、视频设置、持久化数据。 |
UInhyeongOBSGeneral 处理器(性能统计、热键、vendor 请求)在 Subsystem 上没有 GetGeneral() 访问器,请通过 GetClient()->GetGeneral() 访问。
事件
Subsystem 上所有事件委托(如 OnConnected、OnCurrentSceneChanged、OnRecordStateChanged、OnMicActivityChanged)均记录于 Events。每个 Blueprint 事件都有对应的原生 C++ 版本,带有 Native 后缀,用于 lambda 绑定(参见 Native Delegates)。