- Home /
error CS0246 anybody help?
hi in my game i got these two errors:
Assets/scripts/MenuManager.cs(125,18): error CS0246: The type or namespace name MPPlayer' could not be found. Are you missing a using directive or an assembly reference? and Assets/scripts/MenuManager.cs(159,17): error CS0246: The type or namespace name MapSetting' could not be found. Are you missing a using directive or an assembly reference?
here is my code
 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
  
 public class MenuManager : MonoBehaviour
 {
     public MenuManager instance;
  
     public string CurrentMenu;
  
     public string MatchName = "";
     public string MatchPassword = "";
     public int MatchMaxPlayers = 32;
  
     private Vector2 ScrollLobby = Vector2.zero;
  
  
     void Start()
     {
         instance = this;
         CurrentMenu = "Main";
         MatchName = "HeyHeyWelcome " + Random.Range(0, 5000);
     }
  
     void FixedUpdate()
     {
         instance = this;
     }
  
     void OnGUI()
     {
         if (CurrentMenu == "Main")
             Menu_Main();
         if (CurrentMenu == "Lobby")
             Menu_Lobby();
         if (CurrentMenu == "Host")
             Menu_HostGame();
         if (CurrentMenu == "ChoMap")
             Menu_ChooseMap();
     }
  
     public void NavigateTo(string nextmenu)
     {
         CurrentMenu = nextmenu;
     }
  
     private void Menu_Main()
     {
         if (GUI.Button(new Rect(10, 10, 200, 50), "Host Game"))
         {
             NavigateTo("Host");
         }
         if (GUI.Button(new Rect(10, 70, 200, 50), "Refresh"))
         {
             MasterServer.RequestHostList("DeathMatch");
         }
  
         GUI.Label(new Rect(220, 10, 130, 30), "Player Name");
         MultiplayerManager.instance.PlayerName = GUI.TextField(new Rect(350, 10, 150, 30), MultiplayerManager.instance.PlayerName);
         if (GUI.Button(new Rect(510, 10, 100, 30), "Save Name"))
         {
             PlayerPrefs.SetString("PlayerName", MultiplayerManager.instance.PlayerName);
         }
  
        
  
         GUILayout.BeginArea(new Rect(Screen.width - 400, 0, 400, Screen.height), "Server List", "Box");
         GUILayout.Space(20);
         foreach (HostData match in MasterServer.PollHostList())
         {
             GUILayout.BeginHorizontal("Box");
  
             GUILayout.Label(match.gameName);
             if (GUILayout.Button("Connect"))
             {
                 Network.Connect(match);
             }
  
             GUILayout.EndHorizontal();
         }
  
         GUILayout.EndArea();
     }
  
     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);
         }
  
         if (GUI.Button(new Rect(10, 160, 200, 50), "Choose Map"))
         {
             NavigateTo("ChoMap");
         }
  
         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 + 1).ToString());
         MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 31);
  
         if (GUI.Button(new Rect(425, 90, 30, 20), "+"))
             MatchMaxPlayers += 2;
         if (GUI.Button(new Rect(455, 90, 30, 20), "-"))
             MatchMaxPlayers -= 2;
  
         GUI.Label(new Rect(650, 10, 130, 30), MultiplayerManager.instance.CurrentMap.MapName);
     }
  
     private void Menu_Lobby()
     {
         ScrollLobby = GUILayout.BeginScrollView(ScrollLobby, GUILayout.MaxWidth(200));
  
         foreach (MPPlayer pl in MultiplayerManager.instance.PlayerList)
         {
            GUILayout.Box(pl.PlayerName);
         }
  
         GUILayout.EndScrollView();
  
         GUI.Box(new Rect(250, 10, 200, 40), MultiplayerManager.instance.CurrentMap.MapName);
  
         if (Network.isServer)
         {
             if (GUI.Button(new Rect(Screen.width - 200, Screen.height - 80, 200, 40), "Start Match"))
             {
                 MultiplayerManager.instance.networkView.RPC("Client_LoadMultiplayerMap", RPCMode.AllBuffered, MultiplayerManager.instance.CurrentMap.MapLoadName, MultiplayerManager.instance.oldprefix + 1);
                 MultiplayerManager.instance.oldprefix += 1;
                 MultiplayerManager.instance.IsMatchStarted = true;
             }
         }
         if (GUI.Button(new Rect(Screen.width - 200, Screen.height - 40, 200, 40), "Disconnect"))
         {
             Network.Disconnect();
         }
     }
  
     private void Menu_ChooseMap()
     {
         if (GUI.Button(new Rect(10, 10, 200, 50), "Back"))
         {
             NavigateTo("Host");
         }
  
         GUI.Label(new Rect(220, 10, 130, 30), "Choose Map");
         GUILayout.BeginArea(new Rect(350, 10, 150, Screen.height));
  
         foreach(MapSetting map in MultiplayerManager.instance.MapList)
         {
             GUILayout.Button(map.MapName);
         }
  
         GUILayout.EndArea();
     }
  
     void OnServerInitialized()
     {
         NavigateTo("Lobby");
     }
  
     void OnConnectedToServer()
     {
         NavigateTo("Lobby");
     }
  
     void OnDisconnectedFromServer(NetworkDisconnection info)
     {
         NavigateTo("Main");
     }
 }
I think the clue is in the error message - "Are you missing a using directive or an assembly reference?" You're using two classes which do not have using at the start of the file. 
Answer by Jamora · Jun 02, 2013 at 08:15 PM
Those error messages mean that those types can not be found, but you are tring to refrence them in your code. In case the types "MPPlayer" and "MapSettings" are in a different namespace, you need to include that namespace by adding a using the required namespace; at the start of the file. Otherwise, just create new classes in your unity project that are named "MPPlayer" and "MapSettings" 
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                