Script Breaks when Unity Closes

Got a fun one for ya guys this time.

I have a simple script attached to my gameobject. It works perfectly and all, but the problem is that if I save the scene, with the script currently attached to my gameobject, then when I turn Unity back on, the script will no longer work. If I attach it to any new game object it will work, or if I save Unity without the script attached, close it, restart it and reapply the script, the gameobject will then work correctly. But if I save and close Unity with the script on, no matter what I do when I re open it, besides closing it with the script unattached, will make the gameobject work.

Below is the quick code(so if theres a typo my apologies it is correct on my project), and any solutions to this problem would be greatly appreciated. This script is the only one that causes this problem, and it does not matter which gameobject it is attached to, they all error the same way. The button is still on the screen, it just does not function with whatever I put inside the brackets.

function OnGUI()
   if(GUI.RepeatButton(Rect(40,40,50,50), "Up")
         transform.rotation.z = 25;  //this is what does not work anymore

Thank You for your help

more ▼

asked Jul 11 '10 at 05:31 AM

user-3140 (google) gravatar image

user-3140 (google)
3 3 3 6

what OS do you have?

Jul 11 '10 at 10:58 AM spinaljack

Separate the GUI from the scripted object and have the button address the script instead? I have seen a few opinions from long time developers state to keep GUI doing only GUI and all scripting take place elsewhere and pass in vars if they need displaying by the GUI.

Jul 11 '10 at 09:48 PM Rblain

Runnin it on Mac Snowleopard, Ill try to seperate the GUI from the object when I get home, but Ive scripted inside OnGUI before never had this happen, but hey heres hoping :D

Jul 12 '10 at 03:02 AM user-3140 (google)
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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



Answers and Comments



asked: Jul 11 '10 at 05:31 AM

Seen: 749 times

Last Updated: Jul 11 '10 at 05:31 AM