I am totally new to this asset. Watched some tutorials and followed the initial one. Unity version 2021.3.30f1.
I wanted to go a step further and actually influence something in my scene, change a material by script when I click a specific answer.
the script:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MaterialSwitcher : MonoBehaviour
{
public GameObject materialGO;
private Material currentMaterial;
public Material newMaterial;
public void ReplaceMaterial()
{
Renderer renderer = materialGO.GetComponent<Renderer>();
Material currentMaterial = renderer.material;
currentMaterial = newMaterial;
}
}
I also cannot drag and drop the game object that holds the script and the input in the inspector that I need... what the flip? Why?
It just finds the string name??
I don't know what to do now, is my code wrong (given my intellisense is not working correctly in two programs and idk why), do I use the wrong component, does it not read my script... If somebody were so kind to help this confused beginner out, I'd be very grateful. Pointing me to a relevant video is also okay. I just don't know what's going on.
Thanks in advance for any help.