aha
This commit is contained in:
32
Assets/Mirror/Examples/CouchCoop/Scripts/CanvasScript.cs
Normal file
32
Assets/Mirror/Examples/CouchCoop/Scripts/CanvasScript.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
namespace Mirror.Examples.CouchCoop
|
||||
{
|
||||
public class CanvasScript : MonoBehaviour
|
||||
{
|
||||
public CouchPlayerManager couchPlayerManager; // Sets itself
|
||||
public Button buttonAddPlayer, buttonRemovePlayer; // Make sure to attach these Buttons in the Inspector
|
||||
|
||||
private void Start()
|
||||
{
|
||||
buttonAddPlayer.onClick.AddListener(ButtonAddPlayer);
|
||||
buttonRemovePlayer.onClick.AddListener(ButtonRemovePlayer);
|
||||
}
|
||||
|
||||
private void ButtonAddPlayer()
|
||||
{
|
||||
if (couchPlayerManager == null)
|
||||
{ Debug.Log("Start game first."); return; }
|
||||
|
||||
couchPlayerManager.CmdAddPlayer();
|
||||
}
|
||||
|
||||
private void ButtonRemovePlayer()
|
||||
{
|
||||
if (couchPlayerManager == null)
|
||||
{ Debug.Log("Start game first."); return; }
|
||||
|
||||
couchPlayerManager.CmdRemovePlayer();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user