Files
XCEngine/managed/GameScripts/MeshComponentProbe.cs

61 lines
2.5 KiB
C#

using XCEngine;
namespace Gameplay
{
public sealed class MeshComponentProbe : MonoBehaviour
{
public bool HasMeshFilter;
public bool HasMeshRenderer;
public bool MeshFilterLookupSucceeded;
public bool MeshRendererLookupSucceeded;
public string ObservedInitialMeshPath = string.Empty;
public string ObservedUpdatedMeshPath = string.Empty;
public int ObservedInitialMaterialCount;
public string ObservedInitialMaterial0Path = string.Empty;
public bool ObservedInitialCastShadows;
public bool ObservedInitialReceiveShadows;
public int ObservedInitialRenderLayer;
public int ObservedUpdatedMaterialCount;
public string ObservedUpdatedMaterial1Path = string.Empty;
public bool ObservedUpdatedCastShadows;
public bool ObservedUpdatedReceiveShadows;
public int ObservedUpdatedRenderLayer;
public void Start()
{
HasMeshFilter = HasComponent<MeshFilter>();
HasMeshRenderer = HasComponent<MeshRenderer>();
MeshFilterLookupSucceeded = TryGetComponent(out MeshFilter meshFilter);
MeshRendererLookupSucceeded = TryGetComponent(out MeshRenderer meshRenderer);
if (meshFilter != null)
{
ObservedInitialMeshPath = meshFilter.meshPath;
meshFilter.meshPath = "Meshes/runtime_override.mesh";
ObservedUpdatedMeshPath = meshFilter.meshPath;
}
if (meshRenderer != null)
{
ObservedInitialMaterialCount = meshRenderer.materialCount;
ObservedInitialMaterial0Path = meshRenderer.GetMaterialPath(0);
ObservedInitialCastShadows = meshRenderer.castShadows;
ObservedInitialReceiveShadows = meshRenderer.receiveShadows;
ObservedInitialRenderLayer = meshRenderer.renderLayer;
meshRenderer.SetMaterialPath(1, "Materials/runtime_override.mat");
meshRenderer.castShadows = false;
meshRenderer.receiveShadows = true;
meshRenderer.renderLayer = 11;
ObservedUpdatedMaterialCount = meshRenderer.materialCount;
ObservedUpdatedMaterial1Path = meshRenderer.GetMaterialPath(1);
ObservedUpdatedCastShadows = meshRenderer.castShadows;
ObservedUpdatedReceiveShadows = meshRenderer.receiveShadows;
ObservedUpdatedRenderLayer = meshRenderer.renderLayer;
}
}
}
}