mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Properly check if texture exists
This commit is contained in:
parent
c21f15ac22
commit
608c9bb27f
@ -1,14 +1,14 @@
|
|||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
using NewHorizons.Components.SizeControllers;
|
using NewHorizons.Components.SizeControllers;
|
||||||
|
using NewHorizons.Components.Volumes;
|
||||||
|
using NewHorizons.External.Modules;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
|
using NewHorizons.Utility.OWUtilities;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NewHorizons.External.Modules;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
using NewHorizons.Components.Volumes;
|
|
||||||
using NewHorizons.Utility.OWUtilities;
|
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
@ -64,14 +64,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
// Properly lit shader doesnt work yet
|
// Properly lit shader doesnt work yet
|
||||||
ring.unlit = true;
|
ring.unlit = true;
|
||||||
|
|
||||||
Texture2D ringTexture;
|
var ringTexture = ImageUtilities.GetTexture(mod, ring.texture);
|
||||||
try
|
|
||||||
|
if (ringTexture == null)
|
||||||
{
|
{
|
||||||
ringTexture = ImageUtilities.GetTexture(mod, ring.texture);
|
Logger.LogError($"Couldn't load Ring texture [{ring.texture}]");
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.LogError($"Couldn't load Ring texture:\n{e}");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +82,6 @@ namespace NewHorizons.Builder.Body
|
|||||||
var ringMF = ringGO.AddComponent<MeshFilter>();
|
var ringMF = ringGO.AddComponent<MeshFilter>();
|
||||||
var ringMesh = ringMF.mesh;
|
var ringMesh = ringMF.mesh;
|
||||||
var ringMR = ringGO.AddComponent<MeshRenderer>();
|
var ringMR = ringGO.AddComponent<MeshRenderer>();
|
||||||
var texture = ringTexture;
|
|
||||||
|
|
||||||
if (RingShader == null) RingShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
|
if (RingShader == null) RingShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
|
||||||
if (UnlitRingShader == null) UnlitRingShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
|
if (UnlitRingShader == null) UnlitRingShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
|
||||||
@ -93,14 +89,14 @@ namespace NewHorizons.Builder.Body
|
|||||||
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
|
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
|
||||||
|
|
||||||
var mat = new Material(ring.unlit ? UnlitRingShader : RingShader);
|
var mat = new Material(ring.unlit ? UnlitRingShader : RingShader);
|
||||||
if (texture.width == 1)
|
if (ringTexture.width == 1)
|
||||||
{
|
{
|
||||||
mat = new Material(ring.unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
|
mat = new Material(ring.unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
|
||||||
mat.SetFloat(InnerRadius, 0);
|
mat.SetFloat(InnerRadius, 0);
|
||||||
}
|
}
|
||||||
ringMR.receiveShadows = !ring.unlit;
|
ringMR.receiveShadows = !ring.unlit;
|
||||||
|
|
||||||
mat.mainTexture = texture;
|
mat.mainTexture = ringTexture;
|
||||||
|
|
||||||
// Black holes vanish behind rings
|
// Black holes vanish behind rings
|
||||||
// However if we lower this to where black holes don't vanish, water becomes invisible when seen through rings
|
// However if we lower this to where black holes don't vanish, water becomes invisible when seen through rings
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user