Beispiel #1
0
        internal void SetLight(EntityRecord srcRecord, bool syncVisibility)
        {
            Light srcLight = srcRecord.light;

            if (null == srcLight)
            {
                return;
            }

            LightComponents components = GetOrAddLightComponents();
            Light           destLight  = components.LightComponent;

            if (syncVisibility && this.hasVisibility)
            {
                destLight.enabled = this.visibility.visibleInRender;
            }
            destLight.type      = srcLight.type;
            destLight.color     = srcLight.color;
            destLight.intensity = srcLight.intensity;
            destLight.range     = srcLight.range;
            destLight.spotAngle = srcLight.spotAngle;

#if AT_USE_HDRP
            HDAdditionalLightData destHDLightData = components.HDAdditionalLightDataComponent;
            destHDLightData.SetTypeFromLegacy(srcLight.type);
            destHDLightData.color     = srcLight.color;
            destHDLightData.intensity = srcLight.intensity;
            destHDLightData.range     = srcLight.range;
            destHDLightData.SetSpotAngle(srcLight.spotAngle);
#endif
        }
Beispiel #2
0
//----------------------------------------------------------------------------------------------------------------------

        internal void SetLight(LightData lightData, bool syncVisibility, bool shouldUpdate)
        {
            TransformData  transformData = lightData.transform;
            LightDataFlags flags         = lightData.dataFlags;

            LightComponents components = GetOrAddLightComponents();

            if (!shouldUpdate)
            {
                return;
            }

            Light destLight = components.LightComponent;

#if AT_USE_HDRP
            HDAdditionalLightData destHDLightData = components.HDAdditionalLightDataComponent;
#endif

            if (syncVisibility && transformData.dataFlags.hasVisibility)
            {
                destLight.enabled = transformData.visibility.visibleInRender;
            }

            LightType lightType = lightData.lightType;
            if ((int)lightType != -1)
            {
                destLight.type = lightData.lightType;
#if AT_USE_HDRP
                destHDLightData.SetTypeFromLegacy(lightData.lightType);
#endif
            }

            if (flags.hasShadowType)
            {
                destLight.shadows = lightData.shadowType;
            }

            if (flags.hasColor)
            {
                destLight.color = lightData.color;
#if AT_USE_HDRP
                destHDLightData.color = lightData.color;
#endif
            }

            if (flags.hasIntensity)
            {
                destLight.intensity = lightData.intensity;
#if AT_USE_HDRP
                destHDLightData.intensity = lightData.intensity;
#endif
            }

            if (flags.hasRange)
            {
                destLight.range = lightData.range;
#if AT_USE_HDRP
                destHDLightData.range = lightData.range;
#endif
            }

            if (flags.hasSpotAngle)
            {
                destLight.spotAngle = lightData.spotAngle;
#if AT_USE_HDRP
                destHDLightData.SetSpotAngle(lightData.spotAngle);
#endif
            }
        }