Search Unity

Question The type or namespace name '...' doesn't exist

Discussion in 'Scripting' started by atten0007, Jan 15, 2022.

  1. atten0007

    atten0007

    Joined:
    Jun 25, 2021
    Posts:
    45
    Hi folks,

    I'm currently coding on my game Mikacraft with the Unity game engine. When it's finished, I want to publish it to multiple app stores (e.g. Apple, Google, Microsoft). But there's the error CS0246 in my project (The type or namespace name '...' couldn't be found) and I don't know how to fix it because I'm very new to Unity (I created my Unity ID at the 25th June of 2021). I tried to add 'using UnityEngine.UI' to the three scripts with the compiler error CS0246, but sadly this hasn't worked. If you can tell me, how to fix it, it'd be really nice for me! And in this forum post, I'm not swearing because this isn't good and I don't want to get blocked in this forum.

    Sincerely yours,
    Atten007
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Nobody memorizes error codes, so nobody can help you fix your error without you showing some code, copying and pasting the error, or just provided much better information. Otherwise, the error should tell you exactly what is wrong.
     
  3. atten0007

    atten0007

    Joined:
    Jun 25, 2021
    Posts:
    45
    Here's my source code (in line 12 there's CS0246):

    Code (CSharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. #pragma warning disable 618
    7. namespace UnityStandardAssets.Utility
    8. {
    9.     public class SimpleActivatorMenu : MonoBehaviour
    10.     {
    11.         // An incredibly simple menu which, when given references
    12.         // to gameobjects in the scene
    13.         public UI.Text camSwitchButton;
    14.         public GameObject[] objects;
    15.  
    16.  
    17.         private int m_CurrentActiveObject;
    18.  
    19.  
    20.         private void OnEnable()
    21.         {
    22.             // active object starts from first in array
    23.             m_CurrentActiveObject = 0;
    24.             camSwitchButton.text = objects[m_CurrentActiveObject].name;
    25.         }
    26.  
    27.  
    28.         public void NextCamera()
    29.         {
    30.             int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;
    31.  
    32.             for (int i = 0; i < objects.Length; i++)
    33.             {
    34.                 objects[i].SetActive(i == nextactiveobject);
    35.             }
    36.  
    37.             m_CurrentActiveObject = nextactiveobject;
    38.             camSwitchButton.text = objects[m_CurrentActiveObject].name;
    39.         }
    40.     }
    41. }
    42.  
    43.  
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    I feel like we've already answered this error for you. But first, copy and paste your errors. Because again, nobody cares about error codes.

    Second, you already asked this same question before and were told how to solve it.
    https://forum.unity.com/threads/i-need-help-with-fixing-cs0246.1217232/

    Maybe learn from it so you aren't asking the same questions repeatedly.
     
    Kurt-Dekker likes this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    Remember that generally the forum is not here to fix your typos.

    That's what the compiler is for.

    That's what error messages are for.

    That's what Google is for.

    You made the typo, you fix the typo.

    Here is how:

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.
     
    Ryiah likes this.