Universal render pipeline: 2d light. How to change component values through the script in 2019.3 ?
Hi! I am working on a project in the new version of Unity beta 2019.3 with a new universal renderer. Please tell me how to change the values of "intensity", "color" through the script at 2d light. The standard methods are not suitable for this.
I need it to implement the change of time of day in 2d game.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.Experimental.Rendering.LWRP;
public sealed class SetTimeOfDay : MonoBehaviour
{
UnityEngine.Experimental.Rendering.Universal.Light2D SUN;
public static void LightSetDay()
{
//SUN
//SUN.intensity=1f;
}
public static void LightSetEvening()
{
//SUN
//SUN.intensity=0.5f;
}
public static void LightSetNight()
{
//SUN
//SUN.intensity=0.2f;
}
}
Answer by ALEX_PAINT · Oct 31, 2019 at 09:19 PM
I found a solution!
using UnityEngine.Experimental.Rendering.LWRP;
public class SunScript : MonoBehaviour
{
public UnityEngine.Experimental.Rendering.Universal.Light2D SUN;
void Start()
{
SUN = GetComponent<UnityEngine.Experimental.Rendering.Universal.Light2D>();
}
public void SunSetDay()
{
SUN.intensity= 1f;
}
public void SunSetEvning()
{
SUN.intensity= 0.5f;
}
public void SunSetNight()
{
SUN.intensity= 0.2f;
}
}
Answer by MindMech · Apr 16, 2020 at 11:54 AM
This was a great answer for me, Thank you so much !!!!
Your answer
Follow this Question
Related Questions
2D Lights - Sprite is appearing black in the camera view. 1 Answer
Lights and shadows flickering extremely 1 Answer
How do I blend shadows? 0 Answers
Backside of planes appear black and not transparent? (PBR Shader Graph) 0 Answers
Monitor Screens Look Blurry in Game Window,Game Mode Not rendering Emissive Screens 0 Answers