- Home /
Unity 5 upgrade
How i can make this script working in Unity 5
function Start(){
if(PlayerPrefs.GetInt("RobtyLevel10Save") == 1)
{
gameObject.Find("Level10Locked").renderer.enabled = false;
}
}
function OnMouseEnter(){
renderer.material.color = Color.grey;
}
function OnMouseExit(){
renderer.material.color = Color.white;
}
function OnMouseDown(){
if(PlayerPrefs.GetInt("RobtyLevel10Save") == 1)
{
Application.LoadLevel("level10");
}
}
Update: here is error codes
7,34 BCE0144: 'UnityEngine.GameObject.renderer' is obsolete. Property renderer has been deprecated. Use GetComponent() instead. (UnityUpgradable)
7,43 BCE0019: 'enabled' is not a member of 'UnityEngine.Component'.
12,1 BCE0144: 'UnityEngine.Component.renderer' is obsolete. Property renderer has been deprecated. Use GetComponent() instead. (UnityUpgradable)
12,10 BCE0019: 'material' is not a member of 'UnityEngine.Component'.
16,1 BCE0144: 'UnityEngine.Component.renderer' is obsolete. Property renderer has been deprecated. Use GetComponent() instead. (UnityUpgradable)
16,10 BCE0019: 'material' is not a member of 'UnityEngine.Component'.
It basically tells you what to do, ins$$anonymous$$d of blahblah.renderer
you now need to do, blahblah.GetComponent(Renderer)
. It looks a little more work, but it is more generalised for all components now, and more obvious what the code used to do in the background.
Your answer

Follow this Question
Related Questions
Issues with jump control for player 1 Answer
Is there a way I could combine these scripts? If so, how? 1 Answer
Beginner Question 2 Answers