HELP ME PLEASE!
this error: Assets/ /MainMenu.cs(29,14): error CS0120: An object reference is required to access non-static member `UnityEngine.Renderer.material' script #C: using UnityEngine; using System.Collections;
public class MenuSelecter : MonoBehaviour{
//Меню- главное public bool PlayGame = false; public bool SetsGame = false; public bool ExitGame = false;
public Camera Camera1; public Camera Camera2;
//Меню- Настроек public bool BackMenu = false; //Графика public bool Low = false; public bool Medium = false; public bool High = false; public bool Fantastic = false;
//Use this initialization void Start() {
}
void OnMouseEnter() { Renderer.material.color = Color.black; } void OnMouseExit() { Renderer.material.color = Color.gray; } void OnMouseUp() { if(SetsGame == true) { Application.LoadLevel (1); } if(SetsGame == true) { Camera1.enabled = false; Camera2.enabled = true; } if(ExitGame == true) { Application.Quit(); } //================ if(BackMenu == true) { Camera1.enabled = true; Camera2.enabled = false; } if(Low == true) { QualitySettings.currentLevel = QualityLevel.Simple; } if(Medium == true) { QualitySettings.currentLevel = QualityLevel.Good; } if(High == true) { QualitySettings.currentLevel = QualityLevel.Beautiful; } if(Fantastic == true) { QualitySettings.currentLevel = QualityLevel.Fantastic; } // if(BackMenu == true) { Application.LoadLevel(0); } } }
Answer by IvovdMarel · Jun 27, 2017 at 02:02 PM
You are using Renderer.material.color as opposed to renderer.material.color
Actually, you should use GetComponent<Renderer>().material.color
Also, please keep in mind the following things:
When posting a question here, 'HELP ME PLEASE' is a terrible title. Instead, mention what type of problem you have in your title. This makes it easier for us to help, and also might help other people in the future with a similar problem.
When posting long lines of code, use the code button so it is readable for other
Basically respect peoples time on the forum
Good luck :)