Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Probably really easy but it is confusing me, plz help

Discussion in 'Scripting' started by killacan, Mar 1, 2015.

  1. killacan

    killacan

    Joined:
    Mar 1, 2015
    Posts:
    2
    hello, I'm new to the forum so I have no clue what I am doing, I'm also new to C# (I have 2 weeks of unity and C# experience) , I'm working on a project and creating a main menu using this tutorial,
    , and he crates a menu manager script that looks like this
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MenuMannager : MonoBehaviour
    5. {
    6.     public Menu CurrentMenu;
    7.  
    8.     public void Start()
    9.     {
    10.         ShowMenu (CurrentMenu);
    11.     }
    12.  
    13.     public void ShowMenu(Menu menu)
    14.     {
    15.         if (CurrentMenu != null)
    16.             CurrentMenu.IsOpen = false;
    17.  
    18.         CurrentMenu = menu;
    19.         CurrentMenu.IsOpen = true;
    20.     }
    21. }
    22.  
    but it says, Assets/Scripts/GameControllers/MenuMannager.cs(6,16): error CS0246: The type or namespace name `Menu' could not be found. Are you missing a using directive or an assembly reference?

    I'm using Unity 4.6.2f1
    and I'm doing it exactly like the tutorial video said and when I mouse over the CurrentMenu it shows exactly what i typed, I am really sorry if this is super simple to fix.
     
  2. jallen720

    jallen720

    Joined:
    Feb 22, 2015
    Posts:
    66
    That error is because the class Menu hasn't been created so Unity doesn't know what it is:

    Code (csharp):
    1. public Menu CurrentMenu;
    Menu is probably a class that will be created in the tutorial. Look in the tutorial for where the Menu class is created and follow the instructions there on how to make it.
     
  3. killacan

    killacan

    Joined:
    Mar 1, 2015
    Posts:
    2
    OH MY GOSH, i feel so retarded right now. your right, I did not name the other script Menu, but MainMenu. Fixed all my problems to rename it to MainMenu. Thank you.
     
  4. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    242
    Also remember that double clicking the error should bring you right to the error in the code.

    Makes it a lot easier to debug when you can actually see the problematic line. ;)