I’m having a bit of trouble
I have two simple scripts.
One, is if I press the space key, the emission turns off and will turn on again if I let go of the space bar
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlitsUit : MonoBehaviour
{
//
public Material material;
private void Update()
{
if (UnityEngine.Input.GetKey(KeyCode.Space))
{
material.DisableKeyword("_EMISSION"); ;
}
else
{
material.EnableKeyword("_EMISSION");
}
}
}
The other one is, If I press E, the emission will turn on and If I press D it will turn off.
They both work, but If i combine them, which is needed for the behaviour I want, they “D” Key doesn’t work anymore. It will only turn off for a split second and come on again.
The code for the emission script is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KopLamp : MonoBehaviour
{
public Material material;
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
material.EnableKeyword("_EMISSION");
}
if (Input.GetKeyDown(KeyCode.D))
{
material.DisableKeyword("_EMISSION");
}
}
}
Could someone help me with this?
Thanks!