internal void OnAwake(HierarchyFolder hierarchyFolder)
        {
            if (!initialized)
            {
                Initialize();
            }

            if (EditorApplication.isPlayingOrWillChangePlaymode && !hierarchyFolder.gameObject.IsPrefabAssetOrOpenInPrefabStage())
            {
                PlayModeStripper.OnSceneObjectAwake(hierarchyFolder.gameObject);
                return;
            }

            // Hide flags are reset for all scene instances on scene reload, so we need to reapply them.
            hierarchyFolder.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
            var transform = hierarchyFolder.transform;

            if (transform.hideFlags == HideFlags.None)
            {
                // Don't hide transform in prefabs or prefab instances to avoid internal Unity exceptions
                if (!transform.gameObject.IsPrefabAssetOrInstance())
                {
                    transform.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
                }
                else
                {
                    transform.hideFlags = HideFlags.NotEditable;
                }
            }
            Register(hierarchyFolder);
        }
 private static PlayModeStripper Instance()
 {
     if (instance == null)
     {
         var preferences = HierarchyFolderPreferences.Get();
         instance = new PlayModeStripper(preferences.playModeBehaviour, preferences.playModeStrippingMethod);
         preferences.onPreferencesChanged += instance.OnPreferencesChanged;
     }
     return(instance);
 }
        private void ResetInstance([CanBeNull] HierarchyFolderPreferences preferences)
        {
            if (instance != this || (preferences != null && preferences.playModeBehaviour == playModeStripping && preferences.playModeStrippingMethod == playModeStrippingMethod))
            {
                return;
            }

            SceneManager.sceneLoaded               -= OnSceneLoaded;
            SceneManager.sceneUnloaded             -= OnSceneUnloaded;
            EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
            instance = null;
        }
Пример #4
0
 private void OnPlayModeStateChanged(PlayModeStateChange playModeState)
 {
     switch (playModeState)
     {
     case PlayModeStateChange.ExitingPlayMode:
         instance = null;
         SceneManager.sceneLoaded               -= OnSceneLoaded;
         SceneManager.sceneUnloaded             -= OnSceneUnloaded;
         EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
         break;
     }
 }
Пример #5
0
 private static PlayModeStripper Instance()
 {
     if (instance == null)
     {
         if (!EditorApplication.isPlayingOrWillChangePlaymode)
         {
             instance = new PlayModeStripper(StrippingType.None, default(PlayModeStrippingMethod));
         }
         else
         {
             var preferences = HierarchyFolderPreferences.Get();
             instance = new PlayModeStripper(preferences.playModeBehaviour, preferences.playModeStrippingMethod);
         }
     }
     return(instance);
 }
Пример #6
0
 private void Awake()
 {
     PlayModeStripper.OnSceneObjectAwake(gameObject);
 }