Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Darkathion · Aug 31, 2015 at 10:43 AM · c#menucodepagetitle

Unity coding problem

Hey all I've been having a problem with unity. My Unity hasn't been liking the section of coding "loadingImage.SetActive(true);" saying "UnassignedReferenceException: The variable loadingImage of LoadOnClick has not been assigned." I am unsure as to what to do in this instance as i haven't had this problem before in Unity 5.1.0 the entire section of coding is at the bottom i wanted to ask if anyone could please help me with this thanks.

using UnityEngine; using System.Collections;

public class LoadOnClick : MonoBehaviour {

 public GameObject loadingImage;
 
 public void LoadScene(int level)
 {
     loadingImage.SetActive(true);
     Application.LoadLevel(level);
 }

}

Comment
Add comment · Show 4
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 darthtelle · Aug 31, 2015 at 10:48 AM 1
Share

Are you getting the error when you run the scene in the editor? Which would mean you haven't assigned anything to "loadingImage".

However, the error is also pointing to something called LoadOnClick, which I'm assu$$anonymous$$g is a function, but you haven't provided code for that. If you have a function called that, please provide that as the above code looks valid.

avatar image Darkathion · Aug 31, 2015 at 10:58 AM 0
Share

I'm currently actually following a Unity Tutorial and whats shown above is exactly what is supposed to be used and the only coding so far. I'm trying to develop a $$anonymous$$ain $$anonymous$$enu and in the tutorial the main menu is already working and i have followed it twice exactly and the coding is the only error that keeps occurring

avatar image darthtelle Darkathion · Aug 31, 2015 at 11:08 AM 0
Share

Could you post a link to the tutorial then? And you don't have any other code anywhere?

avatar image Darkathion Darkathion · Sep 01, 2015 at 03:29 AM 0
Share

https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/creating-a-scene-menu this is the link

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by BlackSnow_2 · Sep 01, 2015 at 03:52 AM

It just sounds like you haven't assigned the public variable as the image. The "Of LoadOnClick" is referring to the script's 'name' and it's simply returning a null when searching for the variable.

I may be wrong though, as I can't see your project, only the code and the error.

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 Darkathion · Sep 01, 2015 at 03:54 AM 0
Share

would you know how to check if i have or haven't?

avatar image BlackSnow_2 · Sep 01, 2015 at 03:59 AM 0
Share

@Darkathion Click on the game object you've assigned the script to, find the script in the object's inspector and look for "loadingImage" with a box to the right of it... If the box says something like "loadingImage ($$anonymous$$ISSING)" or "Unassigned" you need to drag the Image object onto the box.

avatar image Darkathion · Sep 02, 2015 at 12:19 AM 0
Share

While fiddling around trying to get what you said to work i found the problem and it was exactly as you said and also another problem thanks a million for the help. Once i get my game to work completely if i ever publish it then ill put your name into the credits

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

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

am getting error CS1519 and I don't know why. If anybody can find out what's wrong. I'm new to C# soooo yeah I'm noob. Assets/Scraips/UpgradeManager.cs(10,1): error CS1519: Unexpected symbol `}' in class, struct, or interface member declaration 0 Answers

Why is my "enemies " leaving the screen? 0 Answers

My components are disappears 1 Answer

esc key oddity 2 Answers

Unity Swipe menu 0 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