x


Enable/Disable GameObject Button script

I'm a beginner in Unity 3D and i need help with creating a script. Here's how it should work. When i click the button 'Flashlight', the GameObject 'Flashlight Real' should be enabled. If the GameObject is already enabled, it should do the opposite. So how do i create this script?

more ▼

asked May 11 '10 at 04:55 PM

TheTechZone gravatar image

TheTechZone
13 5 5 7

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

See this similar Question/Answer.

more ▼

answered May 11 '10 at 05:19 PM

burnumd gravatar image

burnumd
3.3k 22 34 71

I added the code but i get an error message -

Assets/Standard Assets/Scripts/Flashlight Button.js(1,6): UCE0001: ';' expected. Insert a semicolon at the end.

There is a semi-colon at the end

Light myLight = lightPoint.GetComponent("Flashlight Real");

May 12 '10 at 02:45 PM TheTechZone

The snippet posted is in C#.

May 12 '10 at 03:01 PM burnumd

Also, you need to put the if expression inside Update (or similar).

May 12 '10 at 03:04 PM burnumd
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3335
x1095
x789
x215
x134

asked: May 11 '10 at 04:55 PM

Seen: 4625 times

Last Updated: May 11 '10 at 04:55 PM