Hello, I’ve been trying to figure this out on my own through script reference, google, etc, but I can’t seem to do it, so I’ve turned to the community. I’ve got a main menu for my game, it’s pretty simple, just 4 cubes with a text engraving in each that highlight their functions (play, settings, about, quit). When the user mouses over them, they are supposed to move back a bit along the z-axis and turn red, signaling that it is highlighted. So far so good. When the user hits play, the game loads the first level, then if they decide to head back to the main menu, they just pause and select main menu. But now when Unity loads the main menu, the blocks don’t change color! They still move and all, but they stay dull and gray. Here is my code for the menu blocks (they all run the same script):
using UnityEngine;
using System.Collections;
public class MenuButtonScript : MonoBehaviour {
public Color initColor = new Color(0,0,0,0);
public Vector3 initPos = new Vector3(0,0,0);
void Start () {
initColor = gameObject.renderer.material.color;
initPos = gameObject.transform.position;
}
void Update () {
}
void OnMouseOver(){
renderer.material.color -= new Color(0,2f,2f) * Time.deltaTime * 2f;
if(Input.GetMouseButtonDown(0)){
if(gameObject.name == "PlayButton"){
Debug.Log ("play");
Application.LoadLevel(1);
}
else if(gameObject.name == "SettingsButton"){
Debug.Log("settings");
}
else if(gameObject.name == "AboutButton"){
Debug.Log ("about");
}
else if(gameObject.name == "QuitButton"){
Application.Quit();
}
else{}
}
}
void OnMouseEnter(){
transform.position = new Vector3(initPos.x,initPos.y,initPos.z + 10f);
}
void OnMouseExit(){
renderer.material.color = initColor;
transform.position = initPos;
}
}
BTW, you don’t need to explain like I’m a 5 year old, however, I am new to unity. Thanks for any help!
AssetBundle is fetched from a url so you can provide a local url instead of remote. You can also place it in Resources folder.
– fafase