Hi all,
Having a bit of issue,
I can’t get onClick() public functions to send instructions to the server from a client.
It works fine when i’m acquiring inputs from the GetKeyDown function, but I just cant get it to work in a UI, server/client environment.
Help would be appreciated.
Below is my code.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class RPCscript : NetworkBehaviour {
public Material mat;
void Start ()
{
mat.color = Color.white;
if(isServer)
GetComponent<RPCscript>().enabled = false;
if(isClient)
GetComponent<RPCscript>().enabled = true;
}
void Update ()
{
if(Input.GetKeyDown (KeyCode.Q))
{
CmdBlackColor(Color.black);
CmdHello ();
}
if(Input.GetKeyDown (KeyCode.E))
CmdRedColor(Color.red);
}
[Command]
public void CmdBlackColor(Color color)
{
mat.color = color;
}
[Command]
public void CmdHello()
{
Debug.Log ("Button Pressed!");
}
[Command]
public void CmdRedColor(Color color)
{
mat.color = color;
}
}