Start menu problem and tree rendering problem
UPDATE 1: ADDED SCREENCAP FOR ALL COMPONENTS FOR THE BUTTON.
I made a scene thats an start menu for a game, and the buttons i set up wont work. I proofread the code, checked the "interactable" checkbox and looked for any solution, but i didnt find it. The buttons i created:
This one is for the new game, the exit was the same. Scripts:
NEWGAME:
using UnityEngine;
using System.Collections;
public class NEWGAME : MonoBehaviour
{
// When Hovered Turn Object Red
void OnMouseEnter()
{
GetComponent<Renderer>().material.color = Color.red;
}
// When not hovered turn color back
void OnMouseExit()
{
GetComponent<Renderer>().material.color = Color.white;
}
// If button Start is clicked, level load, else the game will quit
void OnMouseDown(){
Application.LoadLevel("Spawn1");
}
}
EXIT:
using UnityEngine;
using System.Collections;
public class EXIT : MonoBehaviour
{
// When Hovered Turn Object Red
void OnMouseEnter()
{
GetComponent<Renderer>().material.color = Color.red;
}
// When not hovered turn color back
void OnMouseExit()
{
GetComponent<Renderer>().material.color = Color.white;
}
// If button Start is clicked, level load, else the game will quit
void OnMouseDown()
{
Application.Quit();
}
}
Additionally, ive been getting an ugly texture rendering problem, the trees show up black on the background of the fog. I tried setting the billboard higher, but its the same. Heres a capture:
Please stick to one question per thread. Please also state what the problem is with your menu.
@Statement The problem with the menu is that the buttons dont respond to click. I tried everything to fix that.
Try making On$$anonymous$$ouseDown public.
Try printing a message to console ins$$anonymous$$d of loading a level;
public void On$$anonymous$$ouseDown()
{
// Application.LoadLevel(string) is obsolete
// Application.LoadLevel("Spawn1");
print("TODO: Load level");
}
No errors in console?
@Statement After making that change, the console returned "The referenced script on this Behaviour is missing!"
Answer by Statement · Dec 20, 2015 at 12:04 AM
The only thing that look strange is that you use Renderer and not Button or Graphic for setting color.
But then I don't know if this is the problem you have.
I don't know what's up with your billboards but my best guess would be that the shader on that material doesn't do fog rendering. Try a different shader that support fog.
@Statement Ill try the new shader if i can find it. That may solve it. Also, ill change the Renderer for Button.
Your answer
![](https://koobas.hobune.stream/wayback/20220612053250im_/https://answers.unity.com/themes/thub/images/avi.jpg)