Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Please help! Scripts

Please help! Scripts

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Please help! Scripts on Sat Jun 13, 2015 10:34 am

GGG22


Member [Lv. 1]
Member [Lv. 1]
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

View user profile

2 Re: Please help! Scripts on Sat Jun 13, 2015 12:58 pm

developer23


Moderator
Moderator
0 errors

View user profile http://masterdevelopers.altervista.org/

3 Re: Please help! Scripts on Sat Jun 13, 2015 12:58 pm

developer23


Moderator
Moderator
The script works

View user profile http://masterdevelopers.altervista.org/

4 Re: Please help! Scripts on Sun Jun 14, 2015 7:35 am

GGG22


Member [Lv. 1]
Member [Lv. 1]
Ok, thanks. I will try again. confused study Exclamation

View user profile

5 Re: Please help! Scripts on Tue Jun 23, 2015 4:57 pm

PitbullM


Member [Lv. 3]
Member [Lv. 3]
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

View user profile

6 Re: Please help! Scripts on Wed Jun 24, 2015 4:05 am

developer23


Moderator
Moderator
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

View user profile http://masterdevelopers.altervista.org/

7 Re: Please help! Scripts on Wed Jun 24, 2015 2:28 pm

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

View user profile http://www.youtube.com/user/misterninjaboy

8 Re: Please help! Scripts on Wed Jun 24, 2015 2:28 pm

moved.

View user profile http://www.youtube.com/user/misterninjaboy

9 Re: Please help! Scripts on Mon Aug 31, 2015 10:50 am

aquilinajake


Member [Lv. 3]
Member [Lv. 3]
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();
        }
    }
}

View user profile http://jakeaquilina.weebly.com/

10 Re: Please help! Scripts on Mon Aug 31, 2015 4:35 pm

BryceCain25


SUPER MODERATOR
SUPER MODERATOR
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

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum