Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error CS0246: The type or namespace _____ could not be found. - What to type in MonoDevelop?

Discussion in 'Scripting' started by Lynxication, Aug 19, 2015.

  1. Lynxication

    Lynxication

    Joined:
    Aug 19, 2015
    Posts:
    2
    How do I fix the error in the title for the type or namespace of "GlowEffectThreshold_26", "MotionBlurEdge" and "ColorCorrectionEffect"?

    I know there's something I need to type and save in the following coding but I don't know what, please help:

    using UnityEngine;
    using System.Collections;

    public class EffectController : MonoBehaviour
    {
    public Generate2DReflection generate2dReflection;
    public GlowEffectThreshold_26 glowEffect;
    public MotionBlurEdge motionBlur;
    public ColorCorrectionEffect colorCorrection;

    void Update()
    {
    if(QualitySettings.currentLevel < QualityLevel.Good)
    {
    if (generate2dReflection)
    generate2dReflection.enabled = false;
    if (glowEffect)
    glowEffect.enabled = false;
    if (motionBlur)
    motionBlur.enabled = false;
    if (colorCorrection)
    colorCorrection.enabled = false;
    }
    else
    {
    if (generate2dReflection)
    generate2dReflection.enabled = true;
    if (glowEffect)
    glowEffect.enabled = true;
    if (motionBlur)
    motionBlur.enabled = true;
    if (colorCorrection)
    colorCorrection.enabled = true;
    }
    }
    }
     
  2. Duugu

    Duugu

    Joined:
    May 23, 2015
    Posts:
    241
    Hm. This code does not make much sense. What is your intention with this?
     
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Please use code tags to make your code more readable. Also, don't summarize your error messages, but paste them exactly as they occur to better help people see your issues.
     
    Lynxication and DonLoquacious like this.
  4. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    @Duugu Looks like he's using a combination of quality settings and null-checking in order to activate or deactivate scripts. Not really complicated, or "doing it the wrong way" in itself, though it IS hard-to-read without code tags.

    @Lynxication Of course, you should absolutely use [code ][/code ] tags, which I'm about to demonstrate. Also, doing this in Update makes no sense- you're setting them to enabled/disabled every single frame for no reason. Whether they're enabled or disabled should be set by the quality control in the options menu, where "saving" will call a function here to change the status of those scripts once.

    Anyways, the way you fix your errors is likely by checking which namespaces each of these scripts uses. It's likely that in the GlowEffectThreshold_26 script, for instance, there's a line at the beginning that says:
    Code (csharp):
    1. namespace StandardAssets.Effects {
    ... or something to that effect. You need to either include that namespace at the top of this script with a:
    Code (csharp):
    1. using StandardAssets.Effects;
    or by qualifying the type directly in the code by changing:
    Code (csharp):
    1. public GlowEffectThreshold_26 glowEffect;
    to something like
    Code (csharp):
    1. public StandardAssets.Effects.GlowEffectThreshold_26 glowEffect;
    Note that these are only examples, and that is NOT the namespace this script is in. You'll need to check the effects scripts for their correct namespaces.

    The alternatives are that you mispelled the class names or that the class names don't match the script names for those classes, which can be a problem for Monobehaviour-derived classes.
     
    Lynxication likes this.
  5. Lynxication

    Lynxication

    Joined:
    Aug 19, 2015
    Posts:
    2
    Thanks guys, it works now. :)
     
  6. gcoope

    gcoope

    Joined:
    Dec 20, 2012
    Posts:
    11
    There's a useful shortcut for this, when you notice a class/namespace hasn't been imported, move your text cursor to it and press ctrl + alt + space and the MonoDevelop intellisense should give you a suggestion of namespace you could import to fix it
     
  7. torres67

    torres67

    Joined:
    Aug 2, 2020
    Posts:
    2
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Move : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    }

    c:\Users\Javier\Desktop\Unity\TUTORIAL\Assets\Scripts\Move.cs(7,7): Error CS0246: The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Move)

    Error CS0246: No se pudo encontrar el tipo o nombre de espacio de nombres 'MonoBehaviour' (falta una directiva de uso o un referencia de ensamblaje?) (CS0246) (Mover)



    I GET THESE ERRORS, CAN SOMEONE HELP ME.?
     
  8. torres67

    torres67

    Joined:
    Aug 2, 2020
    Posts:
    2
    [QUOTE = "Duugu, publicación: 2257213, miembro: 846382"] Hm. Este código no tiene mucho sentido. ¿Cuál es su intención con esto? [/ QUOTE]

    Hello, you can help me.?