protected static System.Collections.Generic.IEnumerable <T> GetObjectsForLightingExplorer <T>() where T : UnityEngine.Component { var objects = Resources.FindObjectsOfTypeAll <T>().Where((T obj) => { return(!EditorUtility.IsPersistent(obj) && !obj.hideFlags.HasFlag(HideFlags.HideInHierarchy) && !obj.hideFlags.HasFlag(HideFlags.HideAndDontSave)); }); var prefabStage = PrefabStageUtility.GetCurrentPrefabStage(); // No prefab mode. if (prefabStage == null) { // Return all object instances in the scene including prefab instances, but not those that are in prefab assets. return(objects); } // In Context prefab mode with Normal rendering mode else if (prefabStage.mode == PrefabStage.Mode.InContext && StageNavigationManager.instance.contextRenderMode == StageUtility.ContextRenderMode.Normal) { // Return all object instances in the scene and objects in the opened prefab asset, but not objects in the opened prefab instance. return(objects.Where((T obj) => { return !StageUtility.IsPrefabInstanceHiddenForInContextEditing(obj.gameObject); })); } // All remaining cases, e.g. In Context with Hidden or GrayedOut rendering mode, or In Isolation prefab mode. else { // Return only objects in the opened prefab asset. return(objects.Where((T obj) => { return EditorSceneManager.IsPreviewSceneObject(obj); })); } }