IsDefined









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

Featured Snippets


File name: PhotonEditor.cs Copy
909     public static void UpdateRpcList()
910     {
911         List additionalRpcs = new List();
912         HashSet currentRpcs = new HashSet();
913
914         var types = GetAllSubTypesInScripts(typeof(MonoBehaviour));
915
916         foreach (var mono in types)
917         {
918             MethodInfo[] methods = mono.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
919
920             foreach (MethodInfo method in methods)
921             {
922                 if (method.IsDefined(typeof(UnityEngine.RPC), false))
923                 {
924                     currentRpcs.Add(method.Name);
925
926                     if (!additionalRpcs.Contains(method.Name) && !PhotonEditor.Current.RpcList.Contains(method.Name))
927                     {
928                         additionalRpcs.Add(method.Name);
929                     }
930                 }
931             }
932         }
933
934         if (additionalRpcs.Count > 0)
935         {
936             // LIMITS RPC COUNT
937             if (additionalRpcs.Count + PhotonEditor.Current.RpcList.Count >= byte.MaxValue)
938             {
939                 if (currentRpcs.Count <= byte.MaxValue)
940                 {
941                     bool clearList = EditorUtility.DisplayDialog(CurrentLang.IncorrectRPCListTitle, CurrentLang.IncorrectRPCListLabel, CurrentLang.RemoveOutdatedRPCsLabel, CurrentLang.CancelButton);
942                     if (clearList)
943                     {
944                         PhotonEditor.Current.RpcList.Clear();
945                         PhotonEditor.Current.RpcList.AddRange(currentRpcs);
946                     }
947                     else
948                     {
949                         return;
950                     }
951                 }
952                 else
953                 {
954                     EditorUtility.DisplayDialog(CurrentLang.FullRPCListTitle, CurrentLang.FullRPCListLabel, CurrentLang.SkipRPCListUpdateLabel);
955                     return;
956                 }
957             }
958
959             additionalRpcs.Sort();
960             PhotonEditor.Current.RpcList.AddRange(additionalRpcs);
961             EditorUtility.SetDirty(PhotonEditor.Current);
962         }
963     }
File name: ServerSettings.cs Copy
19     public static CloudRegionCode Parse(string codeAsString)
20     {
21         codeAsString = codeAsString.ToLower();
22
23         CloudRegionCode code = CloudRegionCode.none;
24         if (Enum.IsDefined(typeof(CloudRegionCode), codeAsString))
25         {
26             code = (CloudRegionCode)Enum.Parse(typeof(CloudRegionCode), codeAsString);
27         }
28
29         return code;
30     }

IsDefined 150 lượt xem

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