"GameObject does not contain a definition for photonView"

afalconer
edited January 2012 in DotNet
What am I doing wrong?
(Latest versions of Unity and Photon client library.)

Here's a sample script:
using UnityEngine;
using System.Collections;

public class TestPhoton : Photon.MonoBehaviour {

	void Start () {
		print (photonView.viewID.isMine);
	}
	
}

Instead of being able to access the photonView component, I am getting an error:
error CS1061: Type `UnityEngine.GameObject' does not contain a definition for `photonView' and no extension method `photonView' of type `UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)

If I add a line to the start of the class such as "PhotonView photonView;" I get an error about photonView being already defined.

Comments

  • With the code there it should theoretically work.
    Are you sure that you didn't do gameObject.photonView by error which will not work as gameObject only exposes unity inbuilt stuff in that way?
    with gameObject you would need to use gameObject.GetComponent<PhotonView>().xxx instead