DisableButton

mail@pastecode.io avatar
unknown
csharp
2 years ago
752 B
2
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

public class SetupLocalPlayer : NetworkBehaviour
{
    public Button thisButton;

    public override void OnStartClient()
    {
        thisButton = GameObject.FindGameObjectWithTag("Butt").GetComponent<Button>();
    }

    void Update()
    {
     if(isLocalPlayer)
        {
            if(Input.GetKeyDown(KeyCode.Space))
            CmdDisableButton();
        }
    }

    [Command]
    public void CmdDisableButton()
    {
        RpcDisableButtonClient();
    }

    [ClientRpc]
    public void RpcDisableButtonClient()
    {
        thisButton.interactable = false;
    }
}