Skip to content

Commit 50de2a4

Browse files
committed
lights: Update prefabs.
1 parent 070aafe commit 50de2a4

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

Runtime/LightConverter.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace VisualPinball.Engine.Unity.Hdrp
2727
{
2828
public class LightConverter : ILightConverter
2929
{
30-
public void UpdateLight(Light light, LightData data)
30+
public void UpdateLight(Light light, LightData data, bool isInsert)
3131
{
3232
// retrieve hdrp light
3333
var hdLight = light.GetComponent<HDAdditionalLightData>();
@@ -38,13 +38,39 @@ public void UpdateLight(Light light, LightData data)
3838

3939
// color and position
4040
hdLight.color = data.Color2.ToUnityColor();
41-
hdLight.intensity = data.Intensity / 4f;
42-
hdLight.range = data.Falloff * 0.001f;
41+
if (!isInsert) {
42+
hdLight.intensity = data.Intensity / 4f;
43+
hdLight.range = data.Falloff * 0.001f;
4344

44-
// TODO: vpe specific data for height
45-
light.transform.localPosition = new Vector3(0f, 0f, 25f);
45+
// TODO: vpe specific data for height
46+
light.transform.localPosition = new Vector3(0f, 0f, 25f);
47+
}
4648

4749
hdLight.EnableShadows(false);
4850
}
51+
52+
public void SetColor(Light light, Color color)
53+
{
54+
var hdLight = light.GetComponent<HDAdditionalLightData>();
55+
if (hdLight != null) {
56+
hdLight.color = color;
57+
}
58+
}
59+
60+
public void SetIntensity(Light light, float intensityLumen)
61+
{
62+
var hdLight = light.GetComponent<HDAdditionalLightData>();
63+
if (hdLight != null) {
64+
hdLight.SetIntensity(intensityLumen, LightUnit.Lumen);
65+
}
66+
}
67+
68+
public void SpotLight(Light light, float outer, float innerPercent)
69+
{
70+
var hdLight = light.GetComponent<HDAdditionalLightData>();
71+
if (hdLight != null) {
72+
hdLight.SetSpotAngle(outer, innerPercent);
73+
}
74+
}
4975
}
5076
}

0 commit comments

Comments
 (0)