I keep getting a null reference when I try to assign ObservedComponent.
Options
I am assigning the PhotonView at runtime and trying to assign it's observed component, when I do I keep getting a null reference on the photonView .ObservedComponent[0] = this. Is there something I am doing wrong or is this a bug, works sometimes then wont work other times I can't reproduce it? I just tried to build the game and it worked and then I tried to build it again and now it tosses the error.
photon = this.gameObject.AddComponent<PhotonView>();
photon.viewID = 33;
photon.ownershipTransfer = OwnershipOption.Takeover;
photon.synchronization = ViewSynchronization.UnreliableOnChange;
photonView .ObservedComponents[0] = this;
0
Comments
-
I believe I understand why, is it because I am attaching the photon at run time with a simple AddCompponent() and not photonInstanciating it?
Let me know if that's the case.0 -
So what is null exactly in mentioned line?
I do not see if you assign something to photonView.0 -
Did you make sure that the ObservedComponents are non-null? It's an array, which is maybe not initialized?
A console output with the callstack might help. Text pls, no screenshots.0