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. Dismiss Notice

Unity error CSO246

Discussion in 'Scripting' started by Dasnout, Jan 9, 2021.

  1. Dasnout

    Dasnout

    Joined:
    Jan 9, 2021
    Posts:
    4
    Hi I'm a complete unity noob so have no clue how to fix this problem. I'm getting the error message in console 'error CS0246: The type or namespace name 'UxmlNamespacePrefix' could not be found (are you missing a using directive or an assembly reference?)'. It's probably something stupid, so here is the code:

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class PlayerController : MonoBehaviour
    7. {
    8.     // Start is called before the first frame update
    9.     void Start()
    10.     {
    11.  
    12.     }
    13.  
    14.     // Update is called once per frame
    15.     void Update()
    16.     {
    17.  
    18.         transform.Translate(0, 0, 1);
    19.     }
    20. }
    I have checked and the name of the class and script are the same as I know that brings up a similar error
    Honestly have no clue, would be very grateful for any help :)
     
    Last edited: Jan 9, 2021
  2. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    341
    On line 2, delete
    Code (CSharp):
    1. [/ICODE]
    Not sure what that's doing there :)

    Also, welcome.
     
  3. Dasnout

    Dasnout

    Joined:
    Jan 9, 2021
    Posts:
    4
    Sorry that was me messing up the forum code system that wasn't on the code. Should've checked the post! Thanks anyway though
     
  4. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    341
    No worries. Copy and paste the full error code. Let's see where the error is. I don't think this script is the problem.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    This has nothing to do with Unity and absolutely nothing to do with the file above. Perhaps you have some stray code from somewhere else in your project? Sometimes the Rider editor is irritating and adds
    using
    statements in a failed effort to be helpful. I'm told Rider can be disabled from doing this but my experience says otherwise.
     
  6. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    341
    An outdated UI package can cause this too. I figured the full error message would point to the culprit.
     
  7. Dasnout

    Dasnout

    Joined:
    Jan 9, 2021
    Posts:
    4
    Library\PackageCache\com.unity.package-manager-ui@2.0.7\Editor\AssemblyInfo.cs(7,12): error CS0246: The type or namespace name 'UxmlNamespacePrefix' could not be found (are you missing a using directive or an assembly reference?)
    This is the full error code, thanks for all the responses!

    Just to clarify I tried to attach this script to a game object but it brought up this error in the console. As well as this, i have tried to attach empty scripts to objects and this error has been brought up

    After a little digging i think i found the code causing the issue, but don't know what the issue is
    Code (CSharp):
    1. using System.Runtime.CompilerServices;
    2. using UnityEditor.Experimental.UIElements;
    3.  
    4. [assembly: InternalsVisibleTo("Unity.PackageManagerCaptain.Editor")]
    5. [assembly: InternalsVisibleTo("Unity.PackageManagerUI.EditorTests")]
    6. #if UNITY_2018_3_OR_NEWER
    7. [assembly: UxmlNamespacePrefix("UnityEditor.PackageManager.UI", "upm")]
    8. #endif
     
    Last edited: Jan 10, 2021
  8. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    341
    Dasnout likes this.
  9. Dasnout

    Dasnout

    Joined:
    Jan 9, 2021
    Posts:
    4
    Thank you so much! This solved the issue
     
    mopthrow likes this.