Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by sonic220 · Nov 11, 2010 at 04:20 PM · variableassign

the variable has not be assigned

Really can't understand where is the error, I've this variable and a prefab assigned (It's a GUI texture)

var matchGUI : GameObject;

and this pice of code in a OnTrigger function:

var matchGUIobj = Instantiate(matchGUI, Vector3(0.15,0.1,0), transform.rotation);

It says that the variable matchGUI has not be assigned, but i've assigned it in the hierarchy, what's the problem?

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by StephanK · Nov 11, 2010 at 04:57 PM

This question is a bit confusing. What exactly did you assign to which Object?

If your script lives in a prefab maybe you assigned an object from your hierarchy as matchGUI? That won't work. You can only assign prefabs to prefabs in your assets.

Comment
Add comment · Show 3 · 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 sonic220 · Nov 11, 2010 at 06:20 PM 0
Share

my script is attached to my character, in the script there's the variable matchGUI, in the hierarchy i've give to this variable a prefab (a guitexture), then in the script i've tryed to instantiate it.

avatar image StephanK · Nov 11, 2010 at 09:54 PM 0
Share

So if you look at your character in the inspector you can see that the variable has the prefab? and the prefab is not empty?

avatar image wilo · Nov 26, 2012 at 09:20 PM 0
Share

I have this exact same issue. This is from the unity Game development essentials ebook where you build a game. I got to this exact spot and get the same error!

avatar image
0

Answer by fireant911 · Oct 22, 2013 at 06:10 PM

I just purchased Will's book and it is great; however, I, too, have come to a halt at this same point with the same error "The variable matchGUI of 'PlayerCollisions' has not been assigned". I have followed the procedures exactly and checked and rechecked everything yet the error still appears... but only after pressing Play' and grabbing the matches. Did anyone ever come up with a solution to this problem?,

Comment
Add comment · 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
0

Answer by MrSteve1 · Oct 25, 2013 at 05:05 PM

Hey Dudes, was suffering from this problem for quite some time, God knows why.... but when I created a prefab of an object that contained a variable that needed a assigning, it applied the same script "TWICE"

Select the object that has the script and scroll down the inspector, maybe you have two scripts!

Hope this helps!

Comment
Add comment · 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
0

Answer by allgood · Feb 18, 2014 at 08:55 PM

StephanK's answer above is correct. you have to select First Person Controller (which the PlayerCollisions script is attached to), drag MatchGUIprefab from Project panel and drop it over Match GUI variable of First Person Controller's Player Collisions (Script) component on Inspector.

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Coding equivalent of Draging an Object into the Inspector (Solved) 1 Answer

Error: an exposed variable in a JavaScript is not a member of that script 1 Answer

Is "transform.position._" an expensive call? 2 Answers

Creating A Class Variable That Works With Any Class 0 Answers

Error message "variable not assigned" ? 1 Answer


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