@@ -53,25 +53,36 @@ internal class ReflectionProbeEditor : Editor
5353
5454 private Hashtable m_CachedGizmoMaterials = new Hashtable ( ) ;
5555
56- static internal class Styles
56+ public static void GetResolutionArray ( ref int [ ] resolutionList , ref GUIContent [ ] resolutionStringList )
5757 {
58- static Styles ( )
58+ if ( Styles . reflectionResolutionValuesArray == null && Styles . reflectionResolutionTextArray == null )
5959 {
60- richTextMiniLabel . richText = true ;
61-
62- // Create a list of cubemap resolutions
63- renderTextureSizesValues . Clear ( ) ;
64- renderTextureSizes . Clear ( ) ;
60+ int cubemapResolution = Mathf . Max ( 1 , ReflectionProbe . minBakedCubemapResolution ) ;
6561
66- int cubemapResolution = ReflectionProbe . minBakedCubemapResolution ;
62+ List < int > envReflectionResolutionValues = new List < int > ( ) ;
63+ List < GUIContent > envReflectionResolutionText = new List < GUIContent > ( ) ;
6764
6865 do
6966 {
70- renderTextureSizesValues . Add ( cubemapResolution ) ;
71- renderTextureSizes . Add ( new GUIContent ( cubemapResolution . ToString ( ) ) ) ;
67+ envReflectionResolutionValues . Add ( cubemapResolution ) ;
68+ envReflectionResolutionText . Add ( new GUIContent ( cubemapResolution . ToString ( ) ) ) ;
7269 cubemapResolution *= 2 ;
7370 }
7471 while ( cubemapResolution <= ReflectionProbe . maxBakedCubemapResolution ) ;
72+
73+ Styles . reflectionResolutionValuesArray = envReflectionResolutionValues . ToArray ( ) ;
74+ Styles . reflectionResolutionTextArray = envReflectionResolutionText . ToArray ( ) ;
75+ }
76+
77+ resolutionList = Styles . reflectionResolutionValuesArray ;
78+ resolutionStringList = Styles . reflectionResolutionTextArray ;
79+ }
80+
81+ static internal class Styles
82+ {
83+ static Styles ( )
84+ {
85+ richTextMiniLabel . richText = true ;
7586 }
7687
7788 public static GUIStyle richTextMiniLabel = new GUIStyle ( EditorStyles . miniLabel ) ;
@@ -101,8 +112,8 @@ static Styles()
101112 public static GUIContent [ ] reflectionProbeMode = { new GUIContent ( "Baked" ) , new GUIContent ( "Custom" ) , new GUIContent ( "Realtime" ) } ;
102113 public static int [ ] reflectionProbeModeValues = { ( int ) ReflectionProbeMode . Baked , ( int ) ReflectionProbeMode . Custom , ( int ) ReflectionProbeMode . Realtime } ;
103114
104- public static List < int > renderTextureSizesValues = new List < int > ( ) ;
105- public static List < GUIContent > renderTextureSizes = new List < GUIContent > ( ) ;
115+ public static int [ ] reflectionResolutionValuesArray = null ;
116+ public static GUIContent [ ] reflectionResolutionTextArray = null ;
106117
107118 public static GUIContent [ ] clearFlags =
108119 {
@@ -481,7 +492,11 @@ public override void OnInspectorGUI()
481492
482493 EditorGUI . indentLevel ++ ;
483494 {
484- EditorGUILayout . IntPopup ( m_Resolution , Styles . renderTextureSizes . ToArray ( ) , Styles . renderTextureSizesValues . ToArray ( ) , Styles . resolutionText , GUILayout . MinWidth ( 40 ) ) ;
495+ int [ ] reflectionResolutionValuesArray = null ;
496+ GUIContent [ ] reflectionResolutionTextArray = null ;
497+ GetResolutionArray ( ref reflectionResolutionValuesArray , ref reflectionResolutionTextArray ) ;
498+
499+ EditorGUILayout . IntPopup ( m_Resolution , reflectionResolutionTextArray , reflectionResolutionValuesArray , Styles . resolutionText , GUILayout . MinWidth ( 40 ) ) ;
485500 EditorGUILayout . PropertyField ( m_HDR ) ;
486501 EditorGUILayout . PropertyField ( m_ShadowDistance ) ;
487502 EditorGUILayout . IntPopup ( m_ClearFlags , Styles . clearFlags , Styles . clearFlagsValues , Styles . clearFlagsText ) ;
@@ -562,13 +577,14 @@ public override void OnPreviewSettings()
562577
563578 public override void OnPreviewGUI ( Rect position , GUIStyle style )
564579 {
565- if ( ! ValidPreviewSetup ( ) )
580+ // Fix for case 939947 where we didn't get the Layout event if the texture was null when changing color
581+ if ( ! ValidPreviewSetup ( ) && Event . current . type != EventType . ExecuteCommand )
566582 {
567583 GUILayout . BeginHorizontal ( ) ;
568584 GUILayout . FlexibleSpace ( ) ;
569585 Color prevColor = GUI . color ;
570586 GUI . color = new Color ( 1 , 1 , 1 , 0.5f ) ;
571- GUILayout . Label ( "Reflection Probe not baked yet" ) ;
587+ GUILayout . Label ( "Reflection Probe not baked/ready yet" ) ;
572588 GUI . color = prevColor ;
573589 GUILayout . FlexibleSpace ( ) ;
574590 GUILayout . EndHorizontal ( ) ;
0 commit comments