在此项目中,您能够访问使用 Visual Effect Graph 制作的示例场景和效果。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

37 行
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if VFX_OUTPUTEVENT_HDRP_10_0_0_OR_NEWER
using UnityEngine.Rendering.HighDefinition;
#endif
namespace UnityEngine.VFX.Utility
{
[RequireComponent(typeof(Light))]
#if VFX_OUTPUTEVENT_HDRP_10_0_0_OR_NEWER
[RequireComponent(typeof(HDAdditionalLightData))]
#endif
class VFXOutputEventPrefabAttributeLightHandler : VFXOutputEventPrefabAttributeAbstractHandler
{
public float brightnessScale = 1.0f;
static readonly int k_Color = Shader.PropertyToID("color");
public override void OnVFXEventAttribute(VFXEventAttribute eventAttribute, VisualEffect visualEffect)
{
var color = eventAttribute.GetVector3(k_Color);
var intensity = color.magnitude;
var c = new Color(color.x, color.y, color.z) / intensity;
intensity *= brightnessScale;
#if VFX_OUTPUTEVENT_HDRP_10_0_0_OR_NEWER
var hdlight = GetComponent<HDAdditionalLightData>();
hdlight.SetColor(c);
hdlight.SetIntensity(intensity);
#else
var light = GetComponent<Light>();
light.color = c;
light.intensity = intensity;
#endif
}
}
}