File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,14 @@ override protected void OnButtonPressed()
47
47
{
48
48
return ;
49
49
}
50
- SceneSettings . m_Instance . LoadCustomSkybox ( ReferenceImage . FileName ) ;
50
+ if ( ReferenceImage . NotLoaded )
51
+ {
52
+ // Load-on-demand.
53
+ ReferenceImage . SynchronousLoad ( ) ;
54
+ }
55
+
56
+
57
+ SceneSettings . m_Instance . LoadCustomSkyboxFromCache ( ReferenceImage . FileName ) ;
51
58
}
52
59
53
60
override public void ResetState ( )
Original file line number Diff line number Diff line change @@ -250,6 +250,32 @@ public void LoadCustomSkybox(string filename)
250
250
}
251
251
}
252
252
253
+ public void LoadCustomSkyboxFromCache ( string filename )
254
+ {
255
+ Texture2D tex = ImageCache . LoadImageCache ( filename ) ;
256
+
257
+ if ( tex == null )
258
+ {
259
+ LoadCustomSkybox ( filename ) ;
260
+ }
261
+ else
262
+ {
263
+ float aspectRatio = tex . width / tex . height ;
264
+ if ( aspectRatio > 1.5 )
265
+ {
266
+ m_CustomSkyboxMaterial = Resources . Load < Material > ( "Environments/CustomSkybox" ) ;
267
+ }
268
+ else
269
+ {
270
+ m_CustomSkyboxMaterial = Resources . Load < Material > ( "Environments/CustomStereoSkybox" ) ;
271
+ }
272
+ m_CustomSkyboxMaterial . mainTexture = tex ;
273
+ m_CustomSkyboxMaterial . SetColor ( "_Tint" , Color . gray ) ;
274
+ RenderSettings . skybox = m_CustomSkyboxMaterial ;
275
+ RenderSettings . ambientMode = AmbientMode . Skybox ;
276
+ }
277
+ }
278
+
253
279
public Quaternion GradientOrientation
254
280
{
255
281
get { return m_GradientSkew ; }
You can’t perform that action at this time.
0 commit comments