UnAllocateViewID









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

Featured Snippets


File name: PhotonNetwork.cs Copy
1988     public static void UnAllocateViewID(int viewID)
1989     {
1990         manuallyAllocatedViewIds.Remove(viewID);
1991
1992         if (networkingPeer.photonViewList.ContainsKey(viewID))
1993         {
1994             Debug.LogWarning(string.Format("UnAllocateViewID() should be called after the PhotonView was destroyed (GameObject.Destroy()). ViewID: {0} still found in: {1}", viewID, networkingPeer.photonViewList[viewID]));
1995         }
1996     }
File name: PhotonView.cs Copy
295     protected internal void OnDestroy()
296     {
297         if (!this.destroyedByPhotonNetworkOrQuit)
298         {
299             PhotonNetwork.networkingPeer.LocalCleanPhotonView(this);
300         }
301
302         if (!this.destroyedByPhotonNetworkOrQuit && !Application.isLoadingLevel)
303         {
304             if (this.instantiationId > 0)
305             {
306                 // if this viewID was not manually assigned (and we're not shutting down or loading a level), you should use PhotonNetwork.Destroy() to get rid of GOs with PhotonViews
307                 Debug.LogError("OnDestroy() seems to be called without PhotonNetwork.Destroy()?! GameObject: " + this.gameObject + " Application.isLoadingLevel: " + Application.isLoadingLevel);
308             }
309             else
310             {
311                 // this seems to be a manually instantiated PV. if it's local, we could warn if the ID is not in the allocated-list
312                 if (this.viewID <= 0)
313                 {
314                     Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is 0. Was it ever (manually) set?", this));
315                 }
316                 else if (this.isMine && !PhotonNetwork.manuallyAllocatedViewIds.Contains(this.viewID))
317                 {
318                     Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is local (isMine) but not in manuallyAllocatedViewIds list. Use UnAllocateViewID() after you destroyed the PV.", this));
319                 }
320             }
321         }
322     }
File name: OnClickDestroy.cs Copy
39     public IEnumerator DestroyRpc()
40     {
41         GameObject.Destroy(this.gameObject);
42         yield return 0; // if you allow 1 frame to pass, the object's OnDestroy() method gets called and cleans up references.
43         PhotonNetwork.UnAllocateViewID(this.photonView.viewID);
44     }

UnAllocateViewID 169 lượt xem

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