- 新建场景Gameone,拼好UI并拖入UI预制体,例如GameoneForm
- 创建GameoneForm脚本挂载在UI预制上,并实现下面两个方法,否则场景UI会歪
- 在DefaultConfig表中添加Scene.Gameone(即场景名)
- 在Scene表中添加场景编号和资源名称
- 在UIForm表中添加界面编号,备注,和资源名称,UI预制的名字要打对
- 在UIFormId中添加新UI预制的名字与编号
- 新建流程ProcedureGameone
using GameFramework;
using GameFramework.DataTable;
using GameFramework.Event;
using GameFramework.Fsm;
using GameFramework.Procedure;
using GameFramework.Resource;
using System.Collections.Generic;
using UnityEngine;
using UnityGameFramework.Runtime;
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
namespace StarForce
{
public class ProcedureGameone : ProcedureBase
{
private const int gameOneSceneId = 5;
public bool changeToGameOne = false;
protected override void OnInit(ProcedureOwner procedureOwner)
{
base.OnInit(procedureOwner);
}
protected override void OnEnter(ProcedureOwner procedureOwner)
{
base.OnEnter(procedureOwner);
GameEntry.Entity.HideAllLoadingEntities();
GameEntry.Entity.HideAllLoadedEntities();
GameEntry.Entity.HideAllLoadingEntities();
GameEntry.Entity.HideAllLoadedEntities();
string[] loadedSceneAssetNames = GameEntry.Scene.GetLoadedSceneAssetNames();
for (int i = 0; i < loadedSceneAssetNames.Length; i++)
{
GameEntry.Scene.UnloadScene(loadedSceneAssetNames[i]);
}
GameEntry.Base.ResetNormalGameSpeed();
int sceneId = procedureOwner.GetData<VarInt>(Constant.ProcedureData.NextSceneId).Value;
IDataTable<DRScene> dRScenes = GameEntry.DataTable.GetDataTable<DRScene>();
DRScene dRScene = dRScenes.GetDataRow(gameOneSceneId);
GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(dRScene.AssetName), this);
GameEntry.UI.OpenUIForm(UIFormId.GameoneForm, this);
}
protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
}
public override