I want to change and set 3 things after setting the new material:
First The shader type to Unlit/Color
Second The albedo color to change it for example to: 255,0,0,255
Third The metallic value from 0 to 1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoorsLockManager : MonoBehaviour
{
public bool locked;
public Color lockedColor = Color.red;
public Color unlockedColor = Color.green;
public Renderer rend;
private GameObject[] doorPlanes;
private void Start()
{
doorPlanes = GameObject.FindGameObjectsWithTag("DoorPlane");
for (int i = 0; i < doorPlanes.Length; i++)
{
rend = doorPlanes[i].GetComponent<Renderer>();
if (locked)
{
rend.material.SetFloat("Metallic", 1);
rend.material.color = lockedColor;
}
else
{
rend.material.color = unlockedColor;
}
}
}
// Update is called once per frame
void Update ()
{
}
}
This line does nothing:
rend.material.SetFloat("Metallic", 1);
This is what I want to change: