• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Redwolve · Jan 08, 2015 at 01:59 AM · javascriptdrop

Why can I not drag and drop a gameobject into my script after declaring the variable in the script.

Alright, I've tried for about 5 hours now to find the solution to this issue, I know I will kick myself in the head when it is solved. It's likely some noob thing I've done.

So here is what I want to do, I want to change a GUI Button to be invisible, I have created the button. The button is in the UIcanvas and looks and works great. I want to create a script with a GameObject var and drag and drop the button I to said script. I have watched this be possible in the 2D Catch Game tutorial. However, when I create this script and go to drop the object into the space on the script for GameObject I get the "no way that's what you want to do symbol".

I just want to be able to utilize the new UI system and not code all of it. Though it feels like I would be better off coding it all. Please help, my head hurts. Lol. Thank you for your time.

Oh yea, I am trying to do this using UnityScript. I have included the UnityEngine.UI library. Even with a newly opened script in monodev with nothing other than adding the following line outside of the functions:

var myButton:GameObject;

Comment

People who like this

0 Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiwasi · Jan 08, 2015 at 02:38 AM 0
Share

Are you dragging the GameObject itself from the hierarchy?

You also cannot drag something from the hierarchy to a prefab in the assets folder.

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Redwolve · Jan 08, 2015 at 02:44 AM

Thanks for your help.

I figured out what I was doing wrong. It was a noob thing after all.

I was trying to drag the object into the script itself in the inspector instead of the object it was attached to.

Comment
lgoyal
Stakk3r

People who like this

2 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiwasi · Jan 08, 2015 at 02:58 AM 0
Share

Good work. You can actually do this with a prefab if you like.

avatar image l3adw01f · May 10, 2016 at 10:09 PM 0
Share

I'm having the same problem ad i cant see whats wrong

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Function being called when statement untrue? 1 Answer

How to treat Input.GetAxis as Input.GetButtonDown? 9 Answers

Get object, which is more optimized? 1 Answer

Where too learn unityscript? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges