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.

Discussion Help!

Discussion in 'Scripting' started by NoSleepKid, Feb 14, 2023.

Thread Status:
Not open for further replies.
  1. NoSleepKid

    NoSleepKid

    Joined:
    Aug 23, 2022
    Posts:
    3
    So, i've been running into some errors, please help me, with fixing some errors, i have This:

    Assets\Scripts\UI Items.cs(5,8): error CS0116: A namespace cannot directly contain members such as fields or methods


    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.SceneManagement;
    3.  
    4.  
    5. public GameObject myObject;
    6.  
    7. void Update()
    8. {
    9.  
    10.     if (input.GetKeyDown(KeyCode.E))
    11.     {
    12.         myObject.SetActive(true);
    13.     }
    14.  
    15. }
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    4,449
  3. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    490
    We're not going to walk you through every last step of learning how to code. Kurt gave you some excellent resources to learn from in your first thread and spiney gave you another one here. Please go read them. The issue you're having here would be extremely obvious if you'd just go do that first.
     
  4. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,816
    Duplicate, low effort, please review rules before posting again.
     
Thread Status:
Not open for further replies.