feat(scripting): add script add-component api
This commit is contained in:
51
managed/GameScripts/MeshRendererEdgeCaseProbe.cs
Normal file
51
managed/GameScripts/MeshRendererEdgeCaseProbe.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class MeshRendererEdgeCaseProbe : MonoBehaviour
|
||||
{
|
||||
public int ObservedInitialMaterialCount;
|
||||
public string ObservedNegativeIndexPath = string.Empty;
|
||||
public string ObservedOutOfRangePathBeforeClear = string.Empty;
|
||||
public string ObservedMaterial0PathAfterNegativeWrite = string.Empty;
|
||||
public string ObservedMaterial1PathAfterNegativeWrite = string.Empty;
|
||||
public int ObservedMaterialCountAfterNegativeWrite;
|
||||
public int ObservedRenderLayerAfterNegativeWrite;
|
||||
public int ObservedMaterialCountAfterClear;
|
||||
public string ObservedMaterial0PathAfterClear = string.Empty;
|
||||
public string ObservedMaterial3PathAfterClear = string.Empty;
|
||||
public bool ObservedCastShadowsAfterClear;
|
||||
public bool ObservedReceiveShadowsAfterClear;
|
||||
public int ObservedRenderLayerAfterClear;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (!TryGetComponent(out MeshRenderer meshRenderer) || meshRenderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ObservedInitialMaterialCount = meshRenderer.materialCount;
|
||||
ObservedNegativeIndexPath = meshRenderer.GetMaterialPath(-1);
|
||||
ObservedOutOfRangePathBeforeClear = meshRenderer.GetMaterialPath(3);
|
||||
|
||||
meshRenderer.SetMaterialPath(-1, "Materials/ignored.mat");
|
||||
|
||||
ObservedMaterial0PathAfterNegativeWrite = meshRenderer.GetMaterialPath(0);
|
||||
ObservedMaterial1PathAfterNegativeWrite = meshRenderer.GetMaterialPath(1);
|
||||
ObservedMaterialCountAfterNegativeWrite = meshRenderer.materialCount;
|
||||
|
||||
meshRenderer.renderLayer = -5;
|
||||
ObservedRenderLayerAfterNegativeWrite = meshRenderer.renderLayer;
|
||||
|
||||
meshRenderer.ClearMaterials();
|
||||
|
||||
ObservedMaterialCountAfterClear = meshRenderer.materialCount;
|
||||
ObservedMaterial0PathAfterClear = meshRenderer.GetMaterialPath(0);
|
||||
ObservedMaterial3PathAfterClear = meshRenderer.GetMaterialPath(3);
|
||||
ObservedCastShadowsAfterClear = meshRenderer.castShadows;
|
||||
ObservedReceiveShadowsAfterClear = meshRenderer.receiveShadows;
|
||||
ObservedRenderLayerAfterClear = meshRenderer.renderLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user