接口与事件
内容播放事件
事件逻辑图
可提供事件
组件 | 组件作用 | 事件/参数 | 触发时机 |
YomovClientManager | 负责跟播控指令事件 | OnSetPlayerHeight | 事件:设置身高 |
OnStartGame | 事件:开始放映 | ||
OnPause | 事件:暂停放映 | ||
OnResume | 事件:恢复放映 | ||
OnSeek | 事件:切换章节 | ||
YomovActManager | SDK的Act和Plot管理器 | OnLoadPlot | 事件:加载下一个Plot |
OnLoadAct | 事件:加载下一个Act | ||
OnUnloadAct | 事件:加载下一个Plot时,下个Plot对应的Act不是当前Act触发的,卸载当前Act | ||
BeforeLoadScene | 事件:切换章节时、加载下个Act时,跳转到对应场景之前触发 | ||
OnLoadLastPlot | 事件:切换到最后一个Plot,或最后一个Plot播完,触发 | ||
OnSwitchActAndPlot | 事件:切换章节触发 | ||
OnChangePlotEvent | 事件:每次加载完Plot触发 | ||
LoadNextPlot | 事件:切换下个Plot | ||
CurrentPlotIndex | 参数:当前Act的Plot索引 | ||
CurrentActIndex | 参数:当前Act的索引 |
源码
内容播放及播控指令操作源码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Yomov
{
public class ContentEventManager : MonoBehaviour
{
[Header("播控指令事件")]
[Tooltip("开始放映")]
public UnityEvent OnStartGame;
[Tooltip("暂停")]
public UnityEvent OnPauseGame;
[Tooltip("恢复")]
public UnityEvent OnResumeGame;
[Tooltip("切换章节")]
public UnityEvent OnSeek;
[Tooltip("设置身高")]
public UnityEvent OnSetPlayerHeight;
[Header("剧情事件")]
public UnityEvent<string> OnLoadPlot;
public UnityEvent<string> OnLoadAct;
// OnUnloadAct
public UnityEvent<string> OnUnloadAct;
// BeforeLoadScene
public UnityEvent OnBeforeLoadScene;
// OnLoadLastPlot
public UnityEvent OnLoadLastPlot;
// OnSwitchActAndPlot
public UnityEvent OnSwitchActAndPlot;
// OnChangePlotEvent
public UnityEvent<string, string> OnChangePlotEvent;
// Start is called before the first frame update
void Start()
{
YomovClientManager.Instance.OnStartGame += StartGame;
YomovClientManager.Instance.OnPause += PauseGame;
YomovClientManager.Instance.OnResume += ResumeGame;
YomovClientManager.Instance.OnSeek += Seek;
YomovClientManager.Instance.OnSetPlayerHeight += SetPlayerHeight;
YomovActManager.Instance.OnLoadPlot += LoadPlot;
YomovActManager.Instance.OnLoadAct += LoadAct;
YomovActManager.Instance.OnUnloadAct += UnloadAct;
YomovActManager.Instance.OnBeforeLoadScene += BeforeLoadScene;
YomovActManager.Instance.OnLoadLastPlot += LoadLastPlot;
YomovActManager.Instance.OnSwitchActAndPlot += SwitchActAndPlot;
YomovActManager.Instance.OnChangePlotEvent += ChangePlotEvent;
}
private void OnDestroy()
{
if(YomovClientManager.Instance != null){
YomovClientManager.Instance.OnStartGame -= StartGame;
YomovClientManager.Instance.OnPause -= PauseGame;
YomovClientManager.Instance.OnResume -= ResumeGame;
YomovClientManager.Instance.OnSeek -= Seek;
YomovClientManager.Instance.OnSetPlayerHeight -= SetPlayerHeight;
}
if(YomovActManager.Instance != null){
YomovActManager.Instance.OnLoadPlot -= LoadPlot;
YomovActManager.Instance.OnLoadAct -= LoadAct;
YomovActManager.Instance.OnUnloadAct -= UnloadAct;
YomovActManager.Instance.OnBeforeLoadScene -= BeforeLoadScene;
YomovActManager.Instance.OnLoadLastPlot -= LoadLastPlot;
YomovActManager.Instance.OnSwitchActAndPlot -= SwitchActAndPlot;
YomovActManager.Instance.OnChangePlotEvent -= ChangePlotEvent;
}
}
private void ResumeGame()
{
Debug.Log("[CEM] ResumeGame");
OnResumeGame?.Invoke();
}
private void PauseGame()
{
Debug.Log("[CEM] PauseGame");
OnPauseGame?.Invoke();
}
private async void StartGame()
{
Debug.Log("[CEM] StartGame");
OnStartGame?.Invoke();
}
private void Seek()
{
Debug.Log("[CEM] Seek");
OnSeek?.Invoke();
}
private void SetPlayerHeight()
{
Debug.Log("[CEM] SetPlayerHeight");
OnSetPlayerHeight?.Invoke();
}
private void LoadPlot(string plotId)
{
// plotId为组件YomovPlotBoundary.id
Debug.Log("[CEM] LoadPlot: " + plotId);
OnLoadPlot?.Invoke(plotId);
}
private void LoadAct(string actId)
{
// actId为组件YomovActDescriptor.id
Debug.Log("[CEM] LoadAct: " + actId);
OnLoadAct?.Invoke(actId);
}
private void UnloadAct(string actId)
{
// actId为组件YomovActDescriptor.id
Debug.Log("[CEM] UnloadAct: " + actId);
OnUnloadAct?.Invoke(actId);
}
private void BeforeLoadScene()
{
Debug.Log("[CEM] BeforeLoadScene");
OnBeforeLoadScene?.Invoke();
}
private void LoadLastPlot()
{
Debug.Log("[CEM] LoadLastPlot");
OnLoadLastPlot?.Invoke();
}
private void SwitchActAndPlot()
{
Debug.Log("[CEM] SwitchActAndPlot");
OnSwitchActAndPlot?.Invoke();
}
private void ChangePlotEvent(string actName, string plotName)
{
// actName为组件YomovActDescriptor.actName
// plotName为组件YomovPlotBoundary.plotName
Debug.Log("[CEM] ChangePlotEvent: " + actName + " " + plotName);
OnChangePlotEvent?.Invoke(actName, plotName);
}
// 获取当前Act和Plot
private void GetActAndPlotIndex()
{
// 当前Act的索引ID
// YomovActManager.Instance.CurrentActIndex
// 当前Act中Plot的索引ID
// YomovActManager.Instance.CurrentPlotIndex
}
// 切换下个Plot
private void NextPlot()
{
YomovActManager.Instance.LoadNextPlot();
}
}
}