HideFlags









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

Featured Snippets


File name: ReorderableListResources.cs Copy
147         public static Texture2D CreatePixelTexture( string name, Color color )
148         {
149             var tex = new Texture2D( 1, 1, TextureFormat.ARGB32, false, true );
150             tex.name = name;
151             tex.hideFlags = HideFlags.HideAndDontSave;
152             tex.filterMode = FilterMode.Point;
153             tex.SetPixel( 0, 0, color );
154             tex.Apply();
155             return tex;
156         }
File name: ReorderableListResources.cs Copy
168         private static void LoadResourceAssets()
169         {
170             var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin;
171             s_Cached = new Texture2D[ skin.Length ];
172
173             for( int i = 0; i < s_Cached.Length; ++i )
174             {
175                 // Get image data (PNG) from base64 encoded strings.
176                 byte[] imageData = Convert.FromBase64String( skin[ i ] );
177
178                 // Gather image size from image data.
179                 int texWidth, texHeight;
180                 GetImageSize( imageData, out texWidth, out texHeight );
181
182                 // Generate texture asset.
183                 var tex = new Texture2D( texWidth, texHeight, TextureFormat.ARGB32, false, true );
184                 tex.hideFlags = HideFlags.HideAndDontSave;
185                 tex.name = "(Generated) ReorderableList:" + i;
186                 tex.filterMode = FilterMode.Point;
187                 tex.LoadImage( imageData );
188
189                 s_Cached[ i ] = tex;
190             }
191
192             s_LightSkin = null;
193             s_DarkSkin = null;
194         }
File name: PhotonNetwork.cs Copy
974     static PhotonNetwork()
975     {
976         #if UNITY_EDITOR
977         if (!EditorApplication.isPlaying && !EditorApplication.isPlayingOrWillChangePlaymode)
978         {
979             //Debug.Log(string.Format("PhotonNetwork.ctor() Not playing {0} {1}", UnityEditor.EditorApplication.isPlaying, UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode));
980             return;
981         }
982
983         // This can happen when you recompile a script IN play made
984         // This helps to surpress some errors, but will not fix breaking
985         PhotonHandler[] photonHandlers = GameObject.FindObjectsOfType(typeof(PhotonHandler)) as PhotonHandler[];
986         if (photonHandlers != null && photonHandlers.Length > 0)
987         {
988             Debug.LogWarning("Unity recompiled. Connection gets closed and replaced. You can connect as 'new' client.");
989             foreach (PhotonHandler photonHandler in photonHandlers)
990             {
991                 //Debug.Log("Handler: " + photonHandler + " photonHandler.gameObject: " + photonHandler.gameObject);
992                 photonHandler.gameObject.hideFlags = 0;
993                 GameObject.DestroyImmediate(photonHandler.gameObject);
994                 Component.DestroyImmediate(photonHandler);
995             }
996         }
997         #endif
998
999         Application.runInBackground = true;
1000
1001         // Set up a MonoBehaviour to run Photon, and hide it
1002         GameObject photonGO = new GameObject();
1003         photonMono = (PhotonHandler)photonGO.AddComponent();
1004         photonGO.name = "PhotonMono";
1005         photonGO.hideFlags = HideFlags.HideInHierarchy;
1006
1007
1008         // Set up the NetworkingPeer and use protocol of PhotonServerSettings
1009         networkingPeer = new NetworkingPeer(photonMono, string.Empty, PhotonNetwork.PhotonServerSettings.Protocol);
1010
1011
1012         // Local player
1013         CustomTypes.Register();
1014     }
File name: PhotonNetwork.cs Copy
1072     public static void InternalCleanPhotonMonoFromSceneIfStuck()
1073     {
1074         PhotonHandler[] photonHandlers = GameObject.FindObjectsOfType(typeof(PhotonHandler)) as PhotonHandler[];
1075         if (photonHandlers != null && photonHandlers.Length > 0)
1076         {
1077             Debug.Log("Cleaning up hidden PhotonHandler instances in scene. Please save it. This is not an issue.");
1078             foreach (PhotonHandler photonHandler in photonHandlers)
1079             {
1080                 // Debug.Log("Removing Handler: " + photonHandler + " photonHandler.gameObject: " + photonHandler.gameObject);
1081                 photonHandler.gameObject.hideFlags = 0;
1082
1083                 if (photonHandler.gameObject != null && photonHandler.gameObject.name == "PhotonMono")
1084                 {
1085                     GameObject.DestroyImmediate(photonHandler.gameObject);
1086                 }
1087
1088                 Component.DestroyImmediate(photonHandler);
1089             }
1090         }
1091     }

HideFlags 126 lượt xem

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