What I want:
- When I press ‘1’ a material shuld be black
- When I press ‘2’ a material shuld be white
- When I press ‘3’ a material shuld be “a skin color (given in RGB value)”
(It’s all ONE material / SAME material)
When I press 1 or 2 I get the result I want.
My problem when I press 3:
- All shadows disapear on my gameObject
- The primary color is white (not a skin color, that I want)
- The secondary color is kinda what I want but the RGB values are wrong
- When I stop my program the material on my player is not the same as when the program started.
4.1) Exampel: I start my program → The material is black → I press 2 and the material becomes white → I stop the program → My material is still white and not black as it was in the start.
public class ColorChange : MonoBehaviour
{
[SerializeField] private Material playerSkin;
public void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha3))
{
//-----------My 1 Idé--------------//
Color test = new Color(217, 130, 52);
playerSkin.SetColor("_Color", test);
//-----------My 2 Idé--------------//
playerSkin.color = new Color(217, 130, 52);
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
playerSkin.SetColor("_Color", Color.black);
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
playerSkin.SetColor("_Color", Color.white);
}
}
}