Skip to content

Commit

Permalink
Merge branch 'fix/improve-image-loading-errors' into eerop
Browse files Browse the repository at this point in the history
  • Loading branch information
eeropomell committed Jun 23, 2024
2 parents 687ed0c + 8c108cf commit 5377539
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Assets/Scripts/GUI/LoadBackgroundImageButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ override protected void OnButtonPressed()
{
return;
}
SceneSettings.m_Instance.LoadCustomSkybox(ReferenceImage.FileName);
if (ReferenceImage.NotLoaded)
{
// Load-on-demand.
ReferenceImage.SynchronousLoad();
}


SceneSettings.m_Instance.LoadCustomSkyboxFromCache(ReferenceImage.FileName);
}

override public void ResetState()
Expand Down
26 changes: 26 additions & 0 deletions Assets/Scripts/SceneSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,32 @@ public void LoadCustomSkybox(string filename)
}
}

public void LoadCustomSkyboxFromCache(string filename)
{
Texture2D tex = ImageCache.LoadImageCache(filename);

if (tex == null)
{
LoadCustomSkybox(filename);
}
else
{
float aspectRatio = tex.width / tex.height;
if (aspectRatio > 1.5)
{
m_CustomSkyboxMaterial = Resources.Load<Material>("Environments/CustomSkybox");
}
else
{
m_CustomSkyboxMaterial = Resources.Load<Material>("Environments/CustomStereoSkybox");
}
m_CustomSkyboxMaterial.mainTexture = tex;
m_CustomSkyboxMaterial.SetColor("_Tint", Color.gray);
RenderSettings.skybox = m_CustomSkyboxMaterial;
RenderSettings.ambientMode = AmbientMode.Skybox;
}
}

public Quaternion GradientOrientation
{
get { return m_GradientSkew; }
Expand Down

0 comments on commit 5377539

Please sign in to comment.