SceneID









How do I use Scene I D
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonConverter.cs Copy
351     static int ConvertNetworkView(NetworkView[] netViews, bool isScene)
352     {
353         for (int i = netViews.Length - 1; i >= 0; i--)
354         {
355             NetworkView netView = netViews[i];
356             PhotonView view = netView.gameObject.AddComponent();
357             if (isScene)
358             {
359                 //Get scene ID
360                 string str = netView.viewID.ToString().Replace("SceneID: ", "");
361                 int firstSpace = str.IndexOf(" ");
362                 str = str.Substring(0, firstSpace);
363                 int oldViewID = int.Parse(str);
364
365                 view.viewID = oldViewID;
366                 EditorUtility.SetDirty(view);
367                 EditorUtility.SetDirty(view.gameObject);
368             }
369             view.observed = netView.observed;
370             if (netView.stateSynchronization == NetworkStateSynchronization.Unreliable)
371             {
372                 view.synchronization = ViewSynchronization.Unreliable;
373             }
374             else if (netView.stateSynchronization == NetworkStateSynchronization.ReliableDeltaCompressed)
375             {
376                 view.synchronization = ViewSynchronization.ReliableDeltaCompressed;
377             }
378             else
379             {
380                 view.synchronization = ViewSynchronization.Off;
381             }
382             DestroyImmediate(netView, true);
383         }
384         AssetDatabase.Refresh();
385         AssetDatabase.SaveAssets();
386
387         return netViews.Length;
388     }
File name: NetworkingPeer.cs Copy
3630     internal protected void LoadLevelIfSynced()
3631     {
3632         if (!PhotonNetwork.automaticallySyncScene || PhotonNetwork.isMasterClient || PhotonNetwork.room == null)
3633         {
3634             return;
3635         }
3636
3637         // check if "current level" is set in props
3638         if (!PhotonNetwork.room.customProperties.ContainsKey(NetworkingPeer.CurrentSceneProperty))
3639         {
3640             return;
3641         }
3642
3643         // if loaded level is not the one defined my master in props, load that level
3644         object sceneId = PhotonNetwork.room.customProperties[NetworkingPeer.CurrentSceneProperty];
3645         if (sceneId is int)
3646         {
3647             if (Application.loadedLevel != (int)sceneId)
3648                 PhotonNetwork.LoadLevel((int)sceneId);
3649         }
3650         else if (sceneId is string)
3651         {
3652             if (Application.loadedLevelName != (string)sceneId)
3653                 PhotonNetwork.LoadLevel((string)sceneId);
3654         }
3655     }

SceneID 123 lượt xem

Gõ tìm kiếm nhanh...