mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using NewHorizons.Utility;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace NewHorizons.Components
|
|
{
|
|
/// <summary>
|
|
/// Used by vessel asset bundle to change materials to the in-game ones.
|
|
/// </summary>
|
|
public class MaterialReplacer : MonoBehaviour
|
|
{
|
|
public string[] materialNames;
|
|
|
|
public void Start()
|
|
{
|
|
Renderer renderer = GetComponent<Renderer>();
|
|
NomaiNodeController nnc = GetComponent<NomaiNodeController>();
|
|
if (renderer != null)
|
|
{
|
|
var materials = materialNames.Select(name => SearchUtilities.FindResourceOfTypeAndName<Material>(name)).ToArray();
|
|
if (renderer is ParticleSystemRenderer psr)
|
|
psr.materials = materials;
|
|
else
|
|
renderer.sharedMaterials = materials;
|
|
}
|
|
else if (nnc != null)
|
|
{
|
|
var materials = materialNames.Select(name => SearchUtilities.FindResourceOfTypeAndName<Material>(name)).ToArray();
|
|
nnc._inactiveMaterial = materials[0];
|
|
nnc._activeMaterial = materials[1];
|
|
}
|
|
}
|
|
}
|
|
}
|