• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Timothy@Orikina · Jul 21, 2012 at 10:05 PM · mainmenu

JS Main menu issues?

Hey Unity! I'm new to Java Script and I am trying to make a Main Menu. Its not working, and I have never seen this error before. Please help.

Thanks in advance!

Code:

 #pragma strict
 var skin:GUISkin;
 private var gldepth = -0.5;
 private var startTime = 0.1;
 var nativeVerticalResolution = 1200.0;
 var scaledResolutionWidth = nativeVerticalResolution / Screen.height * Screen.width;
 var mat:Material;
 private var tris = 0;
 private var verts = 0;
 private var savedTimeScale:float;
 private var pauseFilter;
 private var showfps:boolean;
 private var showtris:boolean;
 private var showvtx:boolean;
 private var showfpsgraph:boolean;
 var lowFPSColor = Color.red;
 var highFPSColor = Color.green;
 var lowFPS = 30;
 var highFPS = 50;
 //var start : GameObject;
 var url = "WebPlayer.html";
 var statColor:Color = Color.yellow;
 var GuiColor:Color = Color.white;
 
 var credits:String[]=[
 
     "Credits:",
 
     "armedunity.com",
 
     "bbb",
 
     "aaa"] ;
 var crediticons:Texture[];
 
 enum Page { None,Main,Options,Credits,Play }
 
 var currentPage:Page;
 private var fpsarray:int[];
 private var fps:float;
 
  
 function EndPage() {
 
     GUILayout.EndArea();
     if (currentPage != Page.Main) {
         ShowBackButton();
     }
 }
 function ShowBackButton() {
 
     if (GUI.Button(Rect(10,10,150,80),"Back")) {
         currentPage = Page.Main;
     }
 }
 function StatControl() {
 
     GUILayout.BeginHorizontal();
     showfps = GUILayout.Toggle(showfps,"FPS");
     showtris = GUILayout.Toggle(showtris,"Triangles");
     showvtx = GUILayout.Toggle(showvtx,"Vertices");
     showfpsgraph = GUILayout.Toggle(showfpsgraph,"FPS Graph");
     GUILayout.EndHorizontal();
 }
 function Qualities() {
 
     switch (QualitySettings.currentLevel) {
 
         case QualityLevel.Fastest:
 
         GUILayout.Label("Fastest");
 
         break;
 
         case QualityLevel.Fast:
 
         GUILayout.Label("Fast");
 
         break;
 
         case QualityLevel.Simple:
 
         GUILayout.Label("Simple");
 
         break;
 
         case QualityLevel.Good:
 
         GUILayout.Label("Good");
 
         break;
 
         case QualityLevel.Beautiful:
 
         GUILayout.Label("Beautiful");
 
         break;
 
         case QualityLevel.Fantastic:
 
         GUILayout.Label("Fantastic");
 
         break;
     }
 }
 function QualityControl() {
 
     GUILayout.BeginHorizontal();
 
     if (GUILayout.Button("Decrease")) {
         QualitySettings.DecreaseLevel();
     }
 
     if (GUILayout.Button("Increase")) {
         QualitySettings.IncreaseLevel();
     }
     GUILayout.EndHorizontal();
 }
 function BeginPage(width,height) {
     scaledResolutionWidth = nativeVerticalResolution / Screen.height * Screen.width;
     GUILayout.BeginArea(Rect(scaledResolutionWidth/2 - 2, nativeVerticalResolution/2 - 2,width,height));
 }
 function VolumeControl() {
 
     GUILayout.Label("Volume");
     AudioListener.volume = GUILayout.HorizontalSlider(AudioListener.volume,0.0,1.0);
 }
 
 private var toolbarInt:int=0;
 private var toolbarStrings: String[]= ["Audio","Graphics","Stats","System"];
 function ShowDevice() {
  
     GUILayout.Label ("Unity player version "+Application.unityVersion);
 
     GUILayout.Label("Graphics: "+SystemInfo.graphicsDeviceName+" "+
 
     SystemInfo.graphicsMemorySize+"MB    "+
 
     SystemInfo.graphicsDeviceVersion+"   "+
 
     SystemInfo.graphicsDeviceVendor);
 
     GUILayout.Label("Shadows: "+SystemInfo.supportsShadows);
 
     GUILayout.Label("Image Effects: "+SystemInfo.supportsImageEffects);
 
     GUILayout.Label("Render Textures: "+SystemInfo.supportsRenderTextures);
  
 
 }
 
 function Start () {
  switch (currentPage){
  case Page.Play: Play(); break;
 
     case Page.Options: ShowToolbar(); break;
 
     case Page.Credits: ShowCredits(); break;
  }
 }
  //pages
 
 function Play() {
  BeginPage(600,600);
  if(GUILayout.Button ("Campaign")) {
  Application.LoadLevel("start");
  }
  EndPage();
  }
  
 function ShowCredits() {
 
      BeginPage(600,600);
 
      for (var credit in credits) {
          GUILayout.Label(credit);
      }
 
      for (var credit in crediticons) {
          GUILayout.Label(credit);
      }
 
      EndPage();
  }
 function ShowToolbar() {
 
     BeginPage(800,250);
     toolbarInt = GUILayout.Toolbar (toolbarInt, toolbarStrings);
 
     switch (toolbarInt) {
 
         case 0: VolumeControl(); break;
 
         case 3: ShowDevice(); break;
 
         case 1: Qualities(); QualityControl(); break;
 
         case 2: StatControl(); break;
     }
     EndPage();
 }
  
 function update(){
  if (GUILayout.Button ("Play")) {
         currentPage = Page.Play;
     }
 
     if (GUILayout.Button ("Multiplayer")) {
         Application.LoadLevel("mp");
     }
 
     if (GUILayout.Button ("Zombies To be added.")) {
         //add zombies
     }
     if (GUILayout.Button ("Options")) {
         currentPage = Page.Options;
     }
     if (GUILayout.Button ("Credits")) {
         currentPage = Page.Credits;
     }
     if (GUILayout.Button ("Quit")) {
         Application.Quit();
     }
 }


Error: Assets/Scripts/mainmenu.js(36,6): BCE0132: The namespace '' already contains a definition for 'Page'.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Jul 21, 2012 at 10:07 PM

You have more than one thing called Page - perhaps you also have a script called Page in addition to the Enum called Page in the script you posted. You can only have one thing with the same name.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image reptilebeats · Jul 21, 2012 at 10:11 PM 0
Share

i second that, the error clearly says theirs already a page, try changing it to something else

avatar image Timothy@Orikina · Jul 21, 2012 at 11:55 PM 0
Share

Oh thank you! I have another yes.

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Changing two different objects renderer colour 1 Answer

MonoDevelop not recognizing other scripts as types 0 Answers

Disable diagonal movement in 3D 1 Answer

Move a gameobject and then move back 1 Answer

Make a tombstone spawn on AI death? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges