Networking: how to sync NetworkViewIDs for level objects on peers?

I think this is a common issue.

I have a level with game objects. How am I supposed to load this level on remote peers so that game objects with NetworkView components were in sync?

To sync NetworkViewIDs you should use Network.Instantiate() or write custom instantiation code which will use Network.AllocateViewID();

I do not like Network.Instantiate because all my objects are already instantiated when level loads. Am I supposed to destroy game objects and recreate them with Network.Instantiate? This is stupid.

And how can I use AllocateViewID? I should invoke an RPC call to send my IDs and to tell clients which game objects these IDs are related to. And how can I specify an exact object via RPC?

EDIT: Do you have an idea how Network.Instantiate internaly works? This method should use an RPC call to send NetworkViewID to all connected peers and how it tells what object to instantiate?

Network.Instantiate works fine, if you clean up all the buffered instantiations. Network.Destroy() does not get buffered like Network.Instantiate, but you could just put a Network.Destroy() call in a buffered RPC call, and then you're golden. (See this answer for more info)

Otherwise, try to do things authoritatively, by spawning them on the server (so they are always owned by the server) and manipulate them from the server.

Yeah allocating id's yourself gives you a bit more control than using Instantiate so you should probably go for the manual allocating. You do indeed to pass and assign the manually allocated viewid's on every client (and the server).

You need one scene networkview to transfer this (or a Network.Instantiated networkView).

I always have one gameobject which I call GameManager or GameSetup that has the games GUI and gameplay scripts on it. This also has a networkview which I use to set up the game and pass the allocated networkviews around with.

i think your synch problem is not related with instantiating gameobjects.What i have done is this: Each peers loads scene but wait for server authentication.When server player loads it sends peers a int parameter that indicates time for loading.Peers receive this call and apply this equation :wait time=(parameter sent by server)-(package time stamp).all peers calculate this including server and when wait time is over they start game simultaneously.I have tested this loading approach with 5 sec network latency and each peer has different hardware for level load.When level loaded, i see that in a 1mbit connection while all players were active and average package rate was 1k/sec in whole network, there was a 20ms latency in all packages.What i mean is this:assume an object named obj receives update from a peer with a latency of 20ms.By the way in my networked game while i was testing this,there were nearly 2k gameobjects with networkview.

As an answer to your question in EDIT, when you attach a networkview to a game object it has a unique id as you mentioned.When you use network.instantiate it calls a rpc in peers wtih a parameter which indicates related gameobjecs->networkview->networkviewid.Built in network handler gets this message and find the prefab which has same id.Then instantiates it.