i need help with a code, i need to change the shader of a obj who is “Vertex Lit” while is not selected and if you click on it the shader changes into “Transparent/Bumped Specular”; if you click in no obj but the camara background, everyone is “Vertex Lit” as it should be the normal.
this a script example in my proyect like should be with the shaders but with GUI.
this script is a component for a gameObject that if you click on it, the text you input in the string should be shown:
public class Character : MonoBehaviour
{
public string myWords = string.Empty;
private void Start ()
{
}
private void Update ()
{
}
public string GetWords ()
{
return myWords;
}
}
and this goes for the camera allowing to click a obj, if you click on another obj and if you click on the camara background:
public class UI_Demo : MonoBehaviour
{
private GameObject clicked = null;
private void Start()
{
}
private void Update ()
{
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.mainCamera.ScreenPointToRay(Input.mousePosition), out hit))
{
if (hit.collider.gameObject.GetComponent<Character>() != null)
clicked = hit.collider.gameObject;
else
clicked = null;
}
else
clicked = null;
}
}
private void OnGUI()
{
if (clicked != null)
GUI.Label(new Rect(15,15,200,25), clicked.GetComponent<Character>().GetWords());
}
}
can anyone help me please i don’t know very much of C# and scripting
you can be in the credits or teach me right here. ty if you are reading this coders!
and sorry for my bad english…