Unity Unirx 可能会用到的一些常用方式
程序员文章站
2024-02-21 17:17:46
...
// 由墙上按钮事件去刷新 判断两个按钮都按了一次了 才会执行逻辑
public void TwoBtnOnClicked()
{
var startBtnEvent = ZFPUIFirstPlayerStartBtn.CurrentBtn.onClick.AsObservable().First();
var wallBtnEvent = ZFPUIFirstPlayerWallBtn.CurrentBtn.onClick.AsObservable().First();
Observable.WhenAll(startBtnEvent, wallBtnEvent).Subscribe(_ =>
{
Debug.Log("加分");
});
}
// 三个玩家都准备好了
public void AllUIPlayerPrepared()
{
ZFPUIFirstPlayerStartBtn[] zFPUIFirstPlayerStartBtns = GetComponentsInChildren<ZFPUIFirstPlayerStartBtn>();
var player1State = Observable.EveryUpdate().Where(_ => !zFPUIFirstPlayerStartBtns[0].CanClick).First();
var player2State = Observable.EveryUpdate().Where(_ => !zFPUIFirstPlayerStartBtns[1].CanClick).First();
var player3State = Observable.EveryUpdate().Where(_ => !zFPUIFirstPlayerStartBtns[2].CanClick).First();
Observable.WhenAll(player1State, player2State, player3State).Subscribe(_ =>
{
Debug.Log("所有玩家都准备好了 可以开始游戏了");
});
}
上一篇: rmi spring resin启动出错
下一篇: 复习一下原始的rmi