Answer the question
In order to leave comments, you need to log in
How to change the lighting color?
Good afternoon. There is a point light. How to write the code correctly to change the color of the lighting to a predefined one when a button is pressed?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScriptingTurnOff : MonoBehaviour
{
private Light superlight;
private Color lightcolor = new Color(255.0f, 25.0f, 0.0f, 255.0f); //это допустим новый цвет освещения
void Start()
{
superlight = GetComponent<Light>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
//superlight.enabled = false;
superlight.enabled = !superlight.enabled;
}
if (Input.GetKeyDown(KeyCode.F))
{
superlight.color = lightcolor;
// вся проблема здесь, потому что если написать superlight.color = Color.gray; цвет изменяется правильно,
// в противном случае получается ахинея
}
}
}
Answer the question
In order to leave comments, you need to log in
Just to complement Dance Macabre
's answer, Unity has two classes for Color and Color32.
just open the documentation and read. what is the difference and it will become clearer where and what to ask.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question