Help

Why this doesnt work?

i use 2017.1.1

public object ViewID
{
get
{
return (!Bs._Loader.unity) ? this.photonView.viewID : this.networkView.viewID;
}
}

Assets/Scripts/Bs.cs(623,58): error CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between PhotonViewID' and UnityEngine.NetworkViewID’

What happens if you try a good old 1960s-era if statement to check your condition, then either return one or the other?

4 Likes

When using inline statements like this, both types being returned have to be the same. I know, it sucks… The one thing JavaScript has going for itself haha.

So your option is either to dig into your network view object and get the int value, if it has that as a property. Or wrap both returns as an object, which Im pretty sure will work.

public object ViewID => (Bs._Loader.unity) ? (object)this.networkView.viewID : (object)this.photonView.viewID;
1 Like