[Error] instantiating GameObject with PhotonView script attached on runtime.

Hello.
I am developing a multiuser app for hololens that lets the users cooperate and manipulate graphics loaded in the scene. There is no problem at all when I load prefabs which contain graphics related components and the PhotonView component as well as other functionality components.

Since that requires these models to be saved as prefabs, I need to generalize this functionality and let users share simple 3d models with each other, with PhotonView and other components attached at runtime.

Instantiating the game objects is done similarly to manual instantiation example found here:

After instantiating, I attach PhotonView and configure it:

GameObject instance = Instantiate(gameObject);
PhotonView photonView = instance.AddComponent<PhotonView>();
photonView.OwnershipTransfer = OwnershipOption.Takeover;
photonView.FindObservables(true);

I keep ending up in the same 2 errors.
The first one occurs when, after instantiation, the master client simply clicks on the gameobject on scene. The error shows up only to the other clients.

Can’t find PhotonView of incoming OwnershipRequest. ViewId no found: -999.

The second error appers when the master client tries to move the gameobject and, again, it shows up only to the other clients.

Rceived OnSerilization for view Id -999. We have no such PhotonView! Ignore this if you’re joining or leaving the room. State: Joined.

Full script attached.Excuse my horrible code.[197701-modelloadmanager.txt|197701]

My suggestion here would be to create some generic Prefab that contains all the components that you are attaching either way in your code.

This can then be instantiated with Photon.Instantiate(...)

Then afterwards you can call some RPC to configure that new object to be shaped into the object you want it to be. Be aware that introducing user-injected data (like for example models) into your software is always a huge security risk (this has to be taken care of if you’d ever want to publicly publish this in any way).

For the configuration you’d need a way to transfer the models from one user to another - not sure if you have already taken care of this?

Let me know if that made sense…

You would need the prefab to already have a photon view component attached.