- Home /
Question by
StianC · Jun 16, 2014 at 01:59 PM ·
gameobjectrpcboolparameters
RPC parameters are "incorrect" - help
I am trying to call an RPC but it keeps telling me that it can't implicitly convert type bool to GameObject. I need to pass in two params, a GameOject and a bool. It is trying to convert the bool to a GameObject. Can anyone tell me what I'm doing wrong?
IEnumerator SetLevelStates()
{
yield return new WaitForSeconds(1.0f);
networkView.RPC("LevelStates", RPCMode.AllBuffered, new GameObject[] { LevelOne, true });
networkView.RPC("LevelStates", RPCMode.AllBuffered, new GameObject[] { LevelTwo, false });
}
[RPC]
public void LevelStates(GameObject Control, bool State)
{
Control.SetActive(State);
foreach (Transform Child in Control.transform)
{
Child.gameObject.SetActive(true);
}
}
Comment
Answer by Landern · Jun 16, 2014 at 02:01 PM
You're passing a GameObject array, the second element is a bool, bool is not a GameObject. You can pass a comma separated list as params[]. Obviously your method takes a GameObject and a bool, make it so.
IEnumerator SetLevelStates()
{
yield return new WaitForSeconds(1.0f);
networkView.RPC("LevelStates", RPCMode.AllBuffered, LevelOne, true );
networkView.RPC("LevelStates", RPCMode.AllBuffered, LevelTwo, false );
}
[RPC]
public void LevelStates(GameObject Control, bool State)
{
Control.SetActive(State);
foreach (Transform Child in Control.transform)
{
Child.gameObject.SetActive(true);
}
}