Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Drag and Drop a game object into public field in inspector

Discussion in 'Editor & General Support' started by burga, May 28, 2016.

  1. burga

    burga

    Joined:
    May 28, 2016
    Posts:
    2
    Hello,

    I'm a total noob and just started learning C#.
    I watched all the beginner videos for programming with unity and now I wanted to try some stuff trial and error style.

    I have the following problem now:
    I attached a script to my FirstPersonCharacter. In that script, the only thing that I wrote was "public GameObject gun;" which I can also see in the inspector now.

    I created a Cylinder and I wanted to drag this object into that field in the inspector, but it just won't attach.
    Why?

    edit: here's a picture:

    http://imgur.com/30He9aK
     
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    You have a script called GameObject. That may the problem.
     
  3. burga

    burga

    Joined:
    May 28, 2016
    Posts:
    2
    You were perfectly right, thank you!