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;

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @i73,

    I moved your discussion to the appropriate section (PUN specific).
    Someone will look into it.
  • i73
    Options
    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.
  • vadim
    vadim mod
    edited May 2016
    Options
    So what is null exactly in mentioned line?
    I do not see if you assign something to photonView.
  • Tobias
    Options
    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.