FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

descriptionPlease help! Scripts

more_horiz
wht's wron? Wherr's the erro? PLEASE Exclamation Exclamation Exclamation Exclamation Exclamation Exclamation Exclamation

using UnityEngine;
using System.Collections;

public class MenuObject : MonoBehaviour {

public bool isStartGame = false;
public bool isExit = false;

void Start() {
renderer.material.color = Color.red;
}

// Change text colors
void OnMouseEnter() {
renderer.material.color = Color.yellow;
}

void OnMouseExit() {
renderer.material.color = Color.red;
}

// Click actions
void OnMouseDown() {
if (isStartGame) {
Application.LoadLevel(1);
}
if (isExit) {
Application.Quit();
}
}
}




Note: I'm brazilian

descriptionRe: Please help! Scripts

more_horiz
0 errors

_________________
Game Developer
YouTube Channel: https://www.youtube.com/channel/UCra7PcIl3WqSsIChgIAmWrA
Website: http://masterdevelopers.altervista.org/

descriptionRe: Please help! Scripts

more_horiz
The script works

_________________
Game Developer
YouTube Channel: https://www.youtube.com/channel/UCra7PcIl3WqSsIChgIAmWrA
Website: http://masterdevelopers.altervista.org/

descriptionRe: Please help! Scripts

more_horiz
Ok, thanks. I will try again. confused study Exclamation

descriptionRe: Please help! Scripts

more_horiz
not that you have renamed the script?
the script name in c # should be like class.

"public class MenuObject: MonoBehaviour{"

file name:
MenuObject.cs

hello Very Happy

descriptionRe: Please help! Scripts

more_horiz
@PitbullM wrote:
not that you have renamed the script?
the script name in c # should be like class.

"public class MenuObject: MonoBehaviour{"

file name:
MenuObject.cs

hello Very Happy

Yes sure Wink

_________________
Game Developer
YouTube Channel: https://www.youtube.com/channel/UCra7PcIl3WqSsIChgIAmWrA
Website: http://masterdevelopers.altervista.org/

descriptionRe: Please help! Scripts

more_horiz
Please post something like this in "help" section next time. Scripts section is for sharing resources, not asking for help.

descriptionRe: Please help! Scripts

more_horiz
moved.

descriptionRe: Please help! Scripts

more_horiz
in unity 5 you need to GetComponent




Code:


using UnityEngine;
using System.Collections;

public class MenuObject : MonoBehaviour
{

    public bool isStartGame = false;
    public bool isExit = false;

    void Start()
    {
        GetComponent<Renderer>().material.color = Color.red;
    }

    // Change text colors
    void OnMouseEnter()
    {
        GetComponent<Renderer>().material.color = Color.yellow;
    }

    void OnMouseExit()
    {
        GetComponent<Renderer>().material.color = Color.red;
    }

    // Click actions
    void OnMouseDown()
    {
        if (isStartGame)
        {
            Application.LoadLevel(1);
        }
        if (isExit)
        {
            Application.Quit();
        }
    }
}

_________________
https://www.youtube.com/channel/UCrS-nC8CYukMmhAKpyq6TCA

descriptionRe: Please help! Scripts

more_horiz
Hi GGG22, welcome to Unity Ninja! Let me start of with saying that
I believe there might be an easier way with changing the rendered material, I believe it is with the MeshRenderer function. However, yes I would look back on the filename as PitbullM mentioned. Make sure both names match the classname and the actual filename in your project.
(Quick Edit)
aquilinajake brings up an interesting subject as Unity 5 utilizes the GetComponent function and no longer utilizes the MeshRenderer function for changing materials at least.

There are quite the few options, just need to here back from ya Smile

-BryceCain25

_________________
-BryceCain25
Permissions in this forum:
You cannot reply to topics in this forum