- Home /
Unity 3.0 help mee
Hello, i have just downloaded unity 3.0 and imported my old project into it.it updated my project and when it opened my project i had to attach my scripts back to all my objects. now the problem is on my main menu. the problem is i have entered this following line in to my script:
menuItems[MenuItem].OnSelected(true);
this line of code is just informing my game object to select the first menu item when the game loads. now in unity 2.6 this worked fine but as soon as downloaded 3.0 this error message keeps coming up:
Assets/Standard Assets/Scripts/MenuManager.js(14,21): BCE0019: 'OnSelected' is not a member of 'UnityEditor.MenuItem'.
CAN ANYONE PLEASE HELP ME
here is the script that is making the first object selectable:
var menuItems: MenuItem[];
var MySong: AudioClip;
var MySong2: AudioClip;
var currentMenuItem: int = 0;
var KeyDelay: float = 0.25;
function Start() { AudioSource.PlayClipAtPoint(MySong2,transform.position);
var lastMenuItem: int = currentMenuItem;
menuItems[MenuItem].OnSelected(true);
while(true) { if(Input.GetAxis("Vertical") > 0.9)
{ AudioSource.PlayClipAtPoint(MySong,transform.position);
lastMenuItem = currentMenuItem;
currentMenuItem--;
if(currentMenuItem < 0) currentMenuItem = 0;
if(lastMenuItem!= currentMenuItem)
menuItems[lastMenuItem].OnSelected(false);
menuItems[currentMenuItem].OnSelected(true);
yield new WaitForSeconds(KeyDelay);
}
else if(Input.GetAxis("Vertical") < -0.9)
{
AudioSource.PlayClipAtPoint(MySong,transform.position);
lastMenuItem = currentMenuItem;
currentMenuItem++;
if(currentMenuItem >= menuItems.length) currentMenuItem = menuItems.length - 1;
if(lastMenuItem!= currentMenuItem)
menuItems[lastMenuItem].OnSelected(false); menuItems[currentMenuItem].OnSelected(true);
yield new WaitForSeconds(KeyDelay);
}
yield;
if (Input.GetAxis("NewGame")){
Application.LoadLevel (1);
}
}
}
Can you please format your code so that we can read it?
on the code formatting. $$anonymous$$enuItem is an editor class and would only affect the editor. How was this supposed to work in-game?
you know you don't need to post every line of code you have, just the relevant bits is fine
Answer by Darky.du · Oct 04, 2010 at 05:14 PM
Had the same problem, i changed my scripts name and designed the array again. Started to work for me at least. Seems unity 3.0 really have something called MenuItem already. Noticed that it highlited the MenuItem in the script, was kinda odd. Hope this helps.
Hmmm i will try that thank you. yea i noticed that in unity 3.0 $$anonymous$$enuItem is highlighted so i should just change the name of the array and it started to work for you. what was you array called before and what did you name it as now? please let me know i think this my actually work thank you very much Darky :) smiles all the way
Isn't this exactly what I suggested earlier?.. I guess I can spare the 15 points from not being the Accepted answer any more; maybe you understood his answer better, so fair enough. But let me point out that you don't have to accept ANY answer until you know for sure that it solves your problem. Test first, THEN give D the points if it worked.
Haha No Bampf your answer is the exact same and it worked lol i don't know how the tick went to this reply lol sorry dude your answer worked :). No i was just writing back because i had nothing to do lol but you are the one that fixed my issue for me and i am very thank full because you helped me a lot :)
Answer by Bampf · Oct 01, 2010 at 01:47 PM
Apparently menuItems[] is an array of MenuItem. But the reason everyone is so confused is that your examples don't look much like Unity's editor MenuItem's. For example, those are used with static functions, and yours aren't.
I'm wondering if maybe your code had its own MenuItem class, and during the conversion it got lost or is now getting overridden by the Unity or .NET MenuItem classes.
Go back to the original Unity 2.6 project and search through all the scripts (filenames and contents) for the string "MenuItem". If there is a class named MenuItem then make sure the same file(s) are in the Unity 3 project. You might also consider renaming your MenuItem class.
(Whatever you try, make sure you keep an unedited copy of the working, unconverted 2.6 project! That's your baseline as you try to get the Unity 3 version working.)
thank you very much you are a great help and all your ideas are great :)
Answer by uni · Sep 29, 2010 at 01:08 PM
This may sound dumb, but, try changing the name of the .js script. Maybe Unity 3 has a menu manager of it's own. I don't know. Just a quick suggestion.
not dumb at all i have tried that as well and same problem thanks 4 the idea buddy
Answer by Bampf · Sep 29, 2010 at 05:15 PM
The error is occurring in a standard asset. Try upgrading the Standard Assets- this should replace the old script with one that was written for Unity 3. (I'm assuming that you didn't edit any of the standard assets- if you did, then this would overwrite your changes to them.)
Instructions for upgrading Standard Assets can be found at the bottom of this manual page.
Thanks for the idea but it still does not work...:( this is the error message that i get when i run the game:
Assets/Standard Assets/Scripts/Utility Scripts/$$anonymous$$y Scripts/$$anonymous$$enu$$anonymous$$anager.js(12,21): BCE0019: 'OnSelected' is not a member of 'UnityEditor.$$anonymous$$enuItem'.
i dont know if that helps lol
I see. You put your script in a folder inside Standard Assets. (As a general rule, best to keep your stuff separate from built-in and third-party scripts. You can for instance drag $$anonymous$$y Scripts folder out of Standard Assets.)
Where did you get this $$anonymous$$enu$$anonymous$$anager.js script from? Are you even using it? It does not appear to have any bearing on in-game menus.
The Script is $$anonymous$$e and it does relate to the gameObjects trust me it worked fine in unity 2.6 also i had some help on the script from a mate
Your answer
Follow this Question
Related Questions
Issues with 3.3 to 3.4 javascript update 1 Answer
Problem with upgrading project to untiy 3. 1 Answer
Missing GameObject properties for upgraded project 1 Answer
Script acts differently since upgrade to Unity 3 5 Answers
Unity 3.0 Upgrade ? 1 Answer