OpChangeGroups
How do I use Op Change Groups
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: LoadbalancingPeer.cs
Copy
433 public virtual bool OpChangeGroups(byte[] groupsToRemove, byte[] groupsToAdd)
434 {
435 if (this.DebugOut >= DebugLevel.ALL)
436 {
437 this.Listener.DebugReturn(DebugLevel.ALL, "OpChangeGroups()");
438 }
439
440 Dictionary
441 if (groupsToRemove != null)
442 {
443 opParameters[(byte)LiteOpKey.Remove] = groupsToRemove;
444 }
445 if (groupsToAdd != null)
446 {
447 opParameters[(byte)LiteOpKey.Add] = groupsToAdd;
448 }
449
450 return this.OpCustom((byte)LiteOpCode.ChangeGroups, opParameters, true, 0);
451 }
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 }
OpChangeGroups 134 lượt xem
Gõ tìm kiếm nhanh...