NonPublic
How do I use Non Public
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
912 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: AnimationCurveUtils.cs
Copy
189 public static void SetAnimationSettings(this AnimationClip animClip, AnimationClipSettings settings)
190 {
191 //Use reflection to get the internal method
192 BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.NonPublic;
193 MethodInfo mInfo = typeof(AnimationUtility).GetMethod("SetAnimationClipSettings", bindingFlags);
194 mInfo.Invoke(null, new object[] { animClip, settings });
195 }
File name: SortingLayerExposedEditor.cs
Copy
103 public static string[] GetSortingLayerNames()
104 {
105 Type internalEditorUtilityType = typeof(UnityEditorInternal.InternalEditorUtility);
106 PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
107 return (string[])sortingLayersProperty.GetValue(null, new object[0]);
108 }
File name: SortingLayerExposedEditor.cs
Copy
111 public int[] GetSortingLayerUniqueIDs()
112 {
113 Type internalEditorUtilityType = typeof(UnityEditorInternal.InternalEditorUtility);
114 PropertyInfo sortingLayerUniqueIDsProperty = internalEditorUtilityType.GetProperty("sortingLayerUniqueIDs", BindingFlags.Static | BindingFlags.NonPublic);
115 return (int[])sortingLayerUniqueIDsProperty.GetValue(null, new object[0]);
116 }
NonPublic 186 lượt xem
Gõ tìm kiếm nhanh...