@@ -53,25 +53,36 @@ internal class ReflectionProbeEditor : Editor
53
53
54
54
private Hashtable m_CachedGizmoMaterials = new Hashtable ( ) ;
55
55
56
- static internal class Styles
56
+ public static void GetResolutionArray ( ref int [ ] resolutionList , ref GUIContent [ ] resolutionStringList )
57
57
{
58
- static Styles ( )
58
+ if ( Styles . reflectionResolutionValuesArray == null && Styles . reflectionResolutionTextArray == null )
59
59
{
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 ) ;
65
61
66
- int cubemapResolution = ReflectionProbe . minBakedCubemapResolution ;
62
+ List < int > envReflectionResolutionValues = new List < int > ( ) ;
63
+ List < GUIContent > envReflectionResolutionText = new List < GUIContent > ( ) ;
67
64
68
65
do
69
66
{
70
- renderTextureSizesValues . Add ( cubemapResolution ) ;
71
- renderTextureSizes . Add ( new GUIContent ( cubemapResolution . ToString ( ) ) ) ;
67
+ envReflectionResolutionValues . Add ( cubemapResolution ) ;
68
+ envReflectionResolutionText . Add ( new GUIContent ( cubemapResolution . ToString ( ) ) ) ;
72
69
cubemapResolution *= 2 ;
73
70
}
74
71
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 ;
75
86
}
76
87
77
88
public static GUIStyle richTextMiniLabel = new GUIStyle ( EditorStyles . miniLabel ) ;
@@ -101,8 +112,8 @@ static Styles()
101
112
public static GUIContent [ ] reflectionProbeMode = { new GUIContent ( "Baked" ) , new GUIContent ( "Custom" ) , new GUIContent ( "Realtime" ) } ;
102
113
public static int [ ] reflectionProbeModeValues = { ( int ) ReflectionProbeMode . Baked , ( int ) ReflectionProbeMode . Custom , ( int ) ReflectionProbeMode . Realtime } ;
103
114
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 ;
106
117
107
118
public static GUIContent [ ] clearFlags =
108
119
{
@@ -481,7 +492,11 @@ public override void OnInspectorGUI()
481
492
482
493
EditorGUI . indentLevel ++ ;
483
494
{
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 ) ) ;
485
500
EditorGUILayout . PropertyField ( m_HDR ) ;
486
501
EditorGUILayout . PropertyField ( m_ShadowDistance ) ;
487
502
EditorGUILayout . IntPopup ( m_ClearFlags , Styles . clearFlags , Styles . clearFlagsValues , Styles . clearFlagsText ) ;
@@ -562,13 +577,14 @@ public override void OnPreviewSettings()
562
577
563
578
public override void OnPreviewGUI ( Rect position , GUIStyle style )
564
579
{
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 )
566
582
{
567
583
GUILayout . BeginHorizontal ( ) ;
568
584
GUILayout . FlexibleSpace ( ) ;
569
585
Color prevColor = GUI . color ;
570
586
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" ) ;
572
588
GUI . color = prevColor ;
573
589
GUILayout . FlexibleSpace ( ) ;
574
590
GUILayout . EndHorizontal ( ) ;
0 commit comments