namespace UnityEngine.Rendering.HighDefinition
{
///
/// Extensions to create new Lights in HDRP.
///
public static class GameObjectExtension
{
///
/// Add a new HDRP Light to a GameObject
///
/// The GameObject on which the light is going to be added
/// The Type of the HDRP light to Add
/// The created HDRP Light component
public static HDAdditionalLightData AddHDLight(this GameObject gameObject, HDLightTypeAndShape lightTypeAndShape)
{
var hdLight = gameObject.AddComponent();
HDAdditionalLightData.InitDefaultHDAdditionalLightData(hdLight);
// Reflector have been change to true by default in the UX, however to not break compatibility
// with previous 2020.2 project that use light scripting we must keep reflector to false for scripted light
hdLight.enableSpotReflector = false;
hdLight.SetLightTypeAndShape(lightTypeAndShape);
return hdLight;
}
///
/// Remove the HD Light components from a GameObject.
///
/// The GameObject on which the light is going to be removed
public static void RemoveHDLight(this GameObject gameObject)
{
var light = gameObject.GetComponent();
var hdLight = gameObject.GetComponent();
// destroy light components in order
CoreUtils.Destroy(hdLight);
CoreUtils.Destroy(light);
}
// TODO: camera functions
}
}