Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Fenuva_Games · May 19, 2013 at 01:16 AM · c#menu

C# script help?

I get a total of 9 errors from this script. Here is an image of the errors I got: alt text

(And here is the script which has these errors, may someone please fix it?)

using UnityEngine; using System.Collections;

public class MenuManager : MonoBehaviour { public string CurrentMenu;

 public string MatchName = "";
 public string MatchPassword = "";
 public int MaxmatchPlayers = 32;
 
 void Start()
 {
     CurrentMenu = "Main";
     
 }
 
 void OnGUI()
 {
     if(CurrentMenu == "Main")
         Menu_Main();
     if(CurrentMenu == "Lobby")
         Menu_Lobby();
     if(CurrentMenu == "Host")
         Menu_HostGame();
 }
 
 public void NavigateTo(string nextmenu)
 {
     CurrentMenu = nextmenu;
 }
 
 private void Menu_Main()
 {
     if(GUI.Button(new Rect(10, 10, 200, 50), "Host game"))
     {
         NavigateTo("Host");
     }
 }        
 
 private void Menu_HostGame()
 {
     //Buttons Host Game
     if(GUI.Button(new Rect(10, 10, 50, 50), "back"))
     {
         NavigateTo("Main");
     }
     
     if(GUI.Button(new Rect(60, 10, 200, 50), "Start Server"))
     {
         
     }
     
     GUI.Label(new Rect(300, 10, 130, 30), "Match Name");
     MatchName = GUI.TextField(new Rect(400, 10,200, 30), MatchName);
     
     GUI.Label(new Rect(300, 50, 130, 30), "Match Password");
     MatchPassword = GUI.PasswordField(new Rect(400, 50, 200, 30), MatchPassword, '*');
     
     GUI.Label(new Rect(300, 90, 130, 30), "Match Max Players");
     string maxuser = GUI.TextField(new Rect(400, 90, 200, 30), MatchMaxPlayers.ToString());
     MatchMaxPlayers = Interpolator.Parse(maxuser);
     MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 32); 
     
 }
 
 private void Menu_Lobby()
 {
     
 }

}

errors2.png (119.3 kB)
Comment
Add comment · Show 1
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 Fenuva_Games · May 19, 2013 at 03:58 AM 0
Share

Could someone please take the time to rewrite the script so that it functions the same, but there are no compile errors?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · May 19, 2013 at 02:42 AM

Whenever you see "cannot convert 'object'", look to see what variable you have not declared, or some sort of issue with your declaration. In this case, you declare the variable on line 3 as:

 public int MaxmatchPlayers = 32;

But your actual use (and I'm assuming this is the variable you wanted to use) is:

 MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 32); 

Note the difference in the two names.

Comment
Add comment · 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
0

Answer by S3dition · May 19, 2013 at 03:26 AM

MaxMatchPlayers is mispelled on declaration (at the top)

GUI.TextField has too many or too few parameters in the overload

GUI.TextField is not a string

Mathf has too many or too few parameters in the overload

You can't use a GameObject as a float.

Look at the rest of the overload error to see what the function accepts and how many arguments you're passing.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

14 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

multi scripts 1 action the same in each. C# 0 Answers

How to make a menu like ironpants 0 Answers


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