view ID 0 error for scene view with ID 1

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(PhotonView))]
public class PhotonSingleInstantiator : MonoBehaviour {

public GameObject[] prefabs;
public PhotonView photonView;

void Start () {
if (photonView == null)
photonView = gameObject.GetPhotonView();
}

void Create (int prefabID) {
int photonID = PhotonNetwork.AllocateViewID();
Debug.Log("View ID: " + photonID);
photonView.RPC("NetCreate", PhotonTargets.AllBuffered, prefabID, photonID);
}

[RPC]
void NetCreate (int prefabID, int photonID) {
GameObject newObject = Instantiate(prefabs[prefabID], transform.position, transform.rotation) as GameObject;
newObject.GetPhotonView().viewID = photonID;
}
}

The Debug.Log("View ID:" + photonID);
returns usually 1001 or 3001

however, as soon as I call PhotonView.RPC it gives me the error that the ID is 0 !!!

I have been wrestling with this bug for hours. Please help!

Comments

  • I found the problem (other than the missing "Photon." in front of "Monobehaviour")

    Apparently, the scene itself became corrupted and had some invisible photon data in it that broke the system. When I created a fresh new scene and set everything up, it worked right away.

    Please fix this bug, it's been haunting me for hours and I've noticed others asking about it!
  • If you can send me the scene with the broken data, then I could reproduce the issue and try to fix it.
    Problem is: The editor code is not deliberately breaking things and I don't know what goes wrong in those cases...

    I'm glad you found a workaround in your case.
  • Sorry Tobias, I overwrote the scene.

    It happened after I dropped a player prefab in the scene. The bug had something to do with switching between scene IDs and runtime-generated ones. When the prefab was deleted, it left some garbage data behind somehow. It doesn't break every time - it's an intermittent bug. Wish I could help further, if I get the bug again I'll package it up and PM it to you via dropbox.
Sign In or Register to comment.