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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

error CS0234: The type or namespace name `UI' does not exist in the namespace `System.Web'.

Discussion in 'Scripting' started by Fusia_, Jul 31, 2018.

  1. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    I have a couple of errors left in my compiler and this is one of them. It's referring to my use of "using System.Web.UI" at the start of my code. I added this as it was apparently a fix for the "does not exist in current context" errors.

    This is the error:

    error CS0234: The type or namespace name `UI' does not exist in the namespace `System.Web'. Are you missing an assembly reference?



    There's also this error that I don't understand, It's been posted into my compiler 3 times...

    ArgumentException: Value does not fall within the expected range.
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit)
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits (System.String method)
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder..ctor ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:194)
    UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:207)
    UnityEditor.SyncVS.SyncIfFirstFileOpenSinceDomainLoad () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:199)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)



    Here's the code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using System.Web.UI;
    6.  
    7. public class SongControl : MonoBehaviour
    8. {
    9.  
    10.     public Transform Left;
    11.     public Transform Right;
    12.     public Transform Up;
    13.     public Transform Down;
    14.  
    15.     public float songlength = 0;
    16.  
    17.     public KeyCode keyLeft;
    18.     public KeyCode keyRight;
    19.     public KeyCode keyUp;
    20.     public KeyCode keyDown;
    21.  
    22.     public static string destroyBleft = "n";
    23.     public static string destroyGright = "n";
    24.     public static string destroyRup = "n";
    25.     public static string destroyOdown = "n";
    26.    
    27.     void FixedUpdate ()
    28.     {
    29.         songlength += Time.deltaTime;
    30.  
    31.         if ((songlength>=.1) && (songlength<=.125))
    32.         {
    33.             Instantiate(Left.position, Left.rotation);
    34.         }
    35.        
    36. }
    37.  
    38. void OnTriggerStay2D(Collider2D other)
    39. {
    40.  
    41.         if ((Input.GetKeyLeft(KeyLeft)) && (other.gameobject.name == "BlueLeft(Clone)"))
    42.         {
    43.             destroyLeft = "y";
    44.         }
    45.  
    46.         if ((Input.GetKeyRight(KeyRight)) && (other.gameobject.name == "GreenRight(Clone)"))
    47.         {
    48.             destroyLeft = "y";
    49.         }
    50.  
    51.         if ((Input.GetKeyUp(KeyUp)) && (other.gameobject.name == "RedUp(Clone)"))
    52.         {
    53.             destroyLeft = "y";
    54.         }
    55.  
    56.         if ((Input.GetKeyDown(KeyDown)) && (other.gameobject.name == "OrangeDown(Clone)"))
    57.         {
    58.             destroyLeft = "y";
    59.         }
    60.  
    61.     }
    62.  
    63. }
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Looks like an editor error to me.

    As for the UI error, what are you using that would use the System.Web.UI namespace to begin with?

    Also, is this your entire code?

    I see destroyBleft as variables but then you try to set destroyLeft in your method
     
  3. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    Honestly, I've just been using tutorials to help me get started with coding and Unity and I don't really know what I'm doing right now. Adding it seemed to work; however, I think that's just hidden the problem from me to hit me further down the line.
    I've removed system.Web.UI from my code and the old errors have returned.

    I used system.Web.UI as it was apparently a fix for:

    error CS0103: The name `destroyleft' does not exist in the current context.

    and

    error CS0117: `UnityEngine.Input' does not contain a definition for `GetKeyRight'

    These being 2 examples and the other errors being similar, just with different names for each other control I attempted to add.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    That's the thing. What is destroyLeft? Are you trying to reference your own variables? What is GetKeyRight and GetKeyLeft used for? Are you wanting to check what mouse button you clicked?
     
  5. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    What I'm trying to do in this script is to allow a note to be destroyed on screen once the matching key is hit. I'm trying to make a game similar to Guitar hero. It will use the arrow keys as the controls for hitting each note and one of the videos I saw told me to use GetKey to check for when an assigned key is hit.

    I think destroyLeft was to be scripted as the protocol to destroy the note once the GetKey becomes True as soon as the note is within the set collision box near the bottom of the screen.
     
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Ok, well, GetKeyUp is probably what you want to use. https://docs.unity3d.com/ScriptReference/Input.GetKeyUp.html

    The GetKey is not key specific. There is no GetKeyLeft, GetKeyRight, GetKeySpace, etc.

    GetKeyUp takes a paramater that says check if this key is now up after being released. So if I push down and then release a key, it triggers a check. The parameter determines if the key I pushed matches and then runs that if statement.

    The next part you need is to determine if a "note" is within the right area when the key is hit. This will determine if you award points and destroy the note. Most likely the static strings were an attempt to do this. But bools would have been better. Though, there are probably better ways of checking if a note is in the proper area for it to be "correct"
     
    Fusia_ likes this.
  7. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    Alright, I get it now... That’s actually helped me understand what I have to do so much better now, I’ll play around with it tomorrow and see how everything works, Thanks!