You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

55 lines
1.9 KiB

using NUnit.Framework;
using UnityEditor;
namespace UnityEngine.Rendering.HighDefinition.Tests
{
class HDLightDataTests
{
GameObject m_Root;
[SetUp]
public void SetUp()
{
if (GraphicsSettings.currentRenderPipeline is not HDRenderPipelineAsset)
Assert.Ignore("This is an HDRP Tests, and the current pipeline is not HDRP.");
m_Root = new GameObject("TEST_HDLightDataTests");
m_Root.AddComponent<Light>();
m_Root.AddComponent<HDAdditionalLightData>();
m_Root.SetActive(false);
}
[TearDown]
public void TearDown()
{
if (m_Root != null)
CoreUtils.Destroy(m_Root);
}
[Test]
[TestCase(LightType.Tube)]
[TestCase(LightType.Disc)]
[TestCase(LightType.Point)]
public void TestUpdateMesh(LightType type)
{
var light = m_Root.GetComponent<Light>();
light.type = type;
var additionalLightData = m_Root.GetComponent<HDAdditionalLightData>();
additionalLightData.displayAreaLightEmissiveMesh = true;
m_Root.GetComponent<HDAdditionalLightData>().UpdateAreaLightEmissiveMesh();
if (type.IsArea())
{
Assert.IsTrue(GraphicsSettings.TryGetRenderPipelineSettings<HDRenderPipelineRuntimeAssets>(out var assets));
string expectedPath = AssetDatabase.GetAssetPath(type == LightType.Tube ? assets.emissiveCylinderMesh : assets.emissiveQuadMesh);
string meshPath = AssetDatabase.GetAssetPath(additionalLightData.m_EmissiveMeshFilter.sharedMesh);
Assert.AreEqual(expectedPath, meshPath);
}
else
{
Assert.IsNull(additionalLightData.m_EmissiveMeshFilter);
}
}
}
}