SetReceivingEnabled
How do I use Set Receiving Enabled
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: NetworkingPeer.cs
Copy
3005 public void SetReceivingEnabled(int group, bool enabled)
3006 {
3007 if (group <= 0)
3008 {
3009 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + group + ". The group number should be at least 1.");
3010 return;
3011 }
3012
3013 if (enabled)
3014 {
3015 if (!this.allowedReceivingGroups.Contains(group))
3016 {
3017 this.allowedReceivingGroups.Add(group);
3018 byte[] groups = new byte[1] { (byte)group };
3019 this.OpChangeGroups(null, groups);
3020 }
3021 }
3022 else
3023 {
3024 if (this.allowedReceivingGroups.Contains(group))
3025 {
3026 this.allowedReceivingGroups.Remove(group);
3027 byte[] groups = new byte[1] { (byte)group };
3028 this.OpChangeGroups(groups, null);
3029 }
3030 }
3031 }
File name: NetworkingPeer.cs
Copy
3034 public void SetReceivingEnabled(int[] enableGroups, int[] disableGroups)
3035 {
3036 List
3037 List
3038
3039 if (enableGroups != null)
3040 {
3041 for (int index = 0; index < enableGroups.Length; index++)
3042 {
3043 int i = enableGroups[index];
3044 if (i <= 0)
3045 {
3046 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + i + ". The group number should be at least 1.");
3047 continue;
3048 }
3049 if (!this.allowedReceivingGroups.Contains(i))
3050 {
3051 this.allowedReceivingGroups.Add(i);
3052 enableList.Add((byte)i);
3053 }
3054 }
3055 }
3056 if (disableGroups != null)
3057 {
3058 for (int index = 0; index < disableGroups.Length; index++)
3059 {
3060 int i = disableGroups[index];
3061 if (i <= 0)
3062 {
3063 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + i + ". The group number should be at least 1.");
3064 continue;
3065 }
3066 if (enableList.Contains((byte)i))
3067 {
3068 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled disableGroups contains a group that is also in the enableGroups: " + i + ".");
3069 continue;
3070 }
3071 if (this.allowedReceivingGroups.Contains(i))
3072 {
3073 this.allowedReceivingGroups.Remove(i);
3074 disableList.Add((byte)i);
3075 }
3076 }
3077 }
3078
3079 this.OpChangeGroups(disableList.Count > 0 ? disableList.ToArray() : null, enableList.Count > 0 ? enableList.ToArray() : null); //Passing a 0 sized array != passing null
3080 }
File name: PhotonNetwork.cs
Copy
2534 /// Enable/disable receiving on given group (applied to PhotonViews)
2538 public static void SetReceivingEnabled(int group, bool enabled)
2539 {
2540 if (!VerifyCanUseNetwork())
2541 {
2542 return;
2543 }
2544 networkingPeer.SetReceivingEnabled(group, enabled);
2545 }
File name: PhotonNetwork.cs
Copy
2549 /// Enable/disable receiving on given groups (applied to PhotonViews)
2553 public static void SetReceivingEnabled(int[] enableGroups, int[] disableGroups)
2554 {
2555 if (!VerifyCanUseNetwork())
2556 {
2557 return;
2558 }
2559 networkingPeer.SetReceivingEnabled(enableGroups, disableGroups);
2560 }
SetReceivingEnabled 117 lượt xem
Gõ tìm kiếm nhanh...