DisableButton

 avatar
unknown
csharp
4 years ago
752 B
5
Indexable
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;
    }
}
Editor is loading...