Error cs1501 unity

This is the code i use to make a menu for my game in unity. made in C#.
using UnityEngine;
using System.Collections;

public class MenuManager : MonoBehaviour {

	public string CurrentMenu;
	
	public string MatchName = "";
	public string MatchPassword = "";
	private string tempplayer;
	public int MatchMaxPlayers = 64;
	
	private Vector2 ScrollLobby = Vector2.zero;
		
    void Start()
    {
        CurrentMenu = "Main";
		MatchName = "Pre-Alpha Test" +Random.Range (0, 5000);
	}
    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");
		}
		
		GUI.Label(new Rect(220,10,130,30), "Player Name");
		MultiplayerManager.instance.PlayerName = GUI.TextField(new Rect(220,30,130,30), MultiplayerManager.instance.PlayerName);
		if(GUI.Button(new Rect(360, 30, 130, 30), "Save Name"))
		{
			PlayerPrefs.SetString("PlayerName", MultiplayerManager.instance.PlayerName);
		}
		
	}
	
	private void Menu_HostGame()
	{
		//Buttons Host Game
		if(GUI.Button(new Rect(10, 10, 200, 50), "Back"))

		{
			NavigateTo("Main");
		}
		if(GUI.Button(new Rect(10, 60, 200, 50), "Start Server"))
		{
			MultiplayerManager.instance.StartServer(MatchName, MatchPassword, MatchMaxPlayers);
		}
		
		GUI.Label(new Rect(220,10,130,30), "Match Name");
		MatchName = GUI.TextField(new Rect(400,10,200,30), MatchName);
		
		GUI.Label(new Rect(220,50,130,30), "Match Password");
		MatchPassword = GUI.PasswordField(new Rect(400,50,200,30), MatchPassword, '*');
		
		GUI.Label(new Rect(220,90,130,30), "Match Max Players");
		GUI.Label(new Rect(400,90,200,30), MatchMaxPlayers.ToString());
		MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 64);
		
			if(GUI.Button(new Rect(425, 90, 25, 30), "+"))
			MatchMaxPlayers += 2;
			if(GUI.Button(new Rect(450, 90, 25, 30), "-"))
			MatchMaxPlayers -= 2;
		
	}
	private void Menu_Lobby()
	{
		ScrollLobby = GUILayout.BeginScrollView(ScrollLobby, GUILayout.MaxWidth(200));
		
		foreach (MPPlayer pl in MultiplayerManager.instance.PlayerList)
		{
			GUILayout.Box(pl.PlayerName);
		}
		
		GUILayout.EndScrollView(ScrollLobby);
	}
	
	void OnServerInitialized()
	{
		NavigateTo("Lobby");
	}
	
	void OnConnectedToServer()
	{
		NavigateTo("Lobby");
	}
}

This is the code i use to make a menu for my game in unity. made in C#.

i get the error listed above and i dont know how to fix it. any help or links would be appreciated.

No overload for method arguments

Не выводит переменную! В чем проблема?
(29,13): error CS1501: No overload for method `Box’ takes `4′ arguments

Используется csharp

       

public int _curLvl;
        public int maxLvl = 100;
        public int Lvl = 1;
        public GUISkin mySkin;

       
        void OnGUI() {
        GUI.skin = mySkin;
        GUI.Box(new Rect(50,35,(Line) * (_curLvl / (float)maxLvl),10),«»,GUI.skin.GetStyle(«Lvl»));
        GUI.Box(new Rect(50,35,Line,10),Lvl,_curLvl + «/» + maxLvl + » xp», GUI.skin.GetStyle(«LvlBar»)); //вывод Lvl
        }

       
        public void AddjustCurrentLvl( int adl) {
        _curLvl += adl;
                if(_curLvl < 0) _curLvl = 0;
                if(_curLvl >= maxLvl) {
                _curLvl = _curLvl maxLvl;
                maxLvl = maxLvl+20;
                Lvl = Lvl + 1;
                }
        }
}

Аватара пользователя
kast96
UNец
 
Сообщения: 21
Зарегистрирован: 09 мар 2012, 12:42

Re: No overload for method arguments

Сообщение seaman 06 авг 2012, 15:50

Ну и что не понятно? Нет функции GUI.Box с четырмя параметрами! Зачем используете то, чего нет?

seaman
Адепт
 
Сообщения: 8351
Зарегистрирован: 24 янв 2011, 12:32
Откуда: Самара

Re: No overload for method arguments

Сообщение rc2f6 22 сен 2012, 09:37

Спасибо!)

[V] Не использовать того чего нет.

Изображение

Аватара пользователя
rc2f6
UNIт
 
Сообщения: 120
Зарегистрирован: 05 окт 2009, 20:19


Вернуться в Почемучка

Кто сейчас на конференции

Сейчас этот форум просматривают: Google [Bot] и гости: 31



This question already has an answer here:

  • Error cs1501 unity3d 1 answer

I keep getting this error when I run my code and I can’t quite see what the problem is:

error CS1501: No overload for method checkStatus’ takes `1′ arguments

In my enemyHealth script I have:

void Update()
{
    checkStatus (0);
}

public void checkStatus()
{
    if (currentHealth > maxHealth)
        currentHealth = maxHealth;

    if (currentHealth <= 0)
        death();
}

and in my playerAttack script I have:

private void Attack()
{
    enemyHealth eh = (enemyHealth)target.GetComponent ();
    eh.checkStatus (-10);
}


Well, the error message should be plain — you’re calling the checkStatus method with a single argument, while it is declared with no arguments.

Either you need to add an argument to the method declaration (and use it somehow), or you need to change the calls to pass no argument.

It seems that your intent is to either lower the health and check if the character survived — if that’s the case, something like this might work:

public void Damage(int amount)
{
  currentHealth -= amount;

  if (currentHealth > maxHealth)
    currentHealth = maxHealth;

  if (currentHealth <= 0)
    death();
}

Permalink

Cannot retrieve contributors at this time

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Compiler Error CS1501

Compiler Error CS1501

07/20/2015

CS1501

CS1501

99a59646-e2c8-4ee5-9785-4a2c1ae77458

Compiler Error CS1501

No overload for method ‘method’ takes ‘number’ arguments

A call was made to a class method, but no definition of the method takes the specified number of arguments.

Example

The following sample generates CS1501.

using System;  
  
namespace ConsoleApplication1  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            ExampleClass ec = new ExampleClass();  
            ec.ExampleMethod();  
            ec.ExampleMethod(10);  
            // The following line causes compiler error CS1501 because
            // ExampleClass does not contain an ExampleMethod that takes  
            // two arguments.  
            ec.ExampleMethod(10, 20);  
        }  
    }  
  
    // ExampleClass contains two overloads for ExampleMethod. One of them
    // has no parameters and one has a single parameter.  
    class ExampleClass  
    {  
        public void ExampleMethod()  
        {  
            Console.WriteLine("Zero parameters");  
        }  
  
        public void ExampleMethod(int i)  
        {  
            Console.WriteLine("One integer parameter.");  
        }  
  
        //// To fix the error, you must add a method that takes two arguments.  
        //public void ExampleMethod (int i, int j)  
        //{  
        //    Console.WriteLine("Two integer parameters.");  
        //}  
    }  
}  

Понравилась статья? Поделить с друзьями:
  • Error cs1061 как исправить
  • Error cs1061 unity
  • Error cs1056 непредусмотренный символ
  • Error cs1056 недопустимый символ
  • Error cs1056 unexpected character unity