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 Hardcore Games · Dec 24, 2014 at 01:31 PM · classclasses

Class definition not recognized after load level

General description: I just migrated my awesome game from unity 3.5 to 4.5. All objects seem to be ok. The game runs, but now it has some extrange behaviour.

Detalis: I have defined a couple of classes inside the Plugin folder, for instance this one:

 using UnityEngine;
 using System;
 using System.Data;
 using System.Collections;
 using System.Collections.Generic;
 
 public class MapsClass : MonoBehaviour {
 
 //Variables or attributes - Start
     public String MapName;
     public String MapLoadName;
     public Texture MapLoadTexture;
     public int MapMaxRunners;
     public int GoldCost;
     public int BronzeCost;
     public int ReqLevel;
     public int FirstPlacePrize;
     public int SecondPlacePrize;
     public int ThirdPlacePrize;
 
 //Variables or attributes - End
     public MapsClass (String mapName,String mapLoadName,Texture mapLoadTexture, int mapMaxRunners, int goldCost, int bronzeCost, int reqLevel, int firstPlacePrize, int secondPlacePrize, int thirdPlacePrize){
         //MapsClass    theMap = new MapsClass();
         MapName = mapName;
         MapLoadName = mapLoadName;        
         MapLoadTexture = mapLoadTexture;
         MapMaxRunners = mapMaxRunners;            
         GoldCost = goldCost;
         BronzeCost = bronzeCost;
         ReqLevel = reqLevel;
         FirstPlacePrize = firstPlacePrize;
         SecondPlacePrize = secondPlacePrize;
         ThirdPlacePrize = thirdPlacePrize;
         
         //return theMap;
     }
 
     public MapsClass(){
         MapName = "";
         MapLoadName = "";
         MapLoadTexture = null;
         MapMaxRunners = 0;
         GoldCost = 0;
         BronzeCost = 0;
         ReqLevel = 0;
         FirstPlacePrize = 0;
         SecondPlacePrize = 0;
         ThirdPlacePrize = 0;
     }
 }

Now, the class is referenced inside a normal JS which holds this instruction: DontDestroyOnLoad(transform.gameObject);

The same script has a variable defined as: var CurrentMap : MapsClass = null;

On running the game, the variable gets its default value. Then, when I hit the "Lets run" button, the expected level is loaded (another proof that the value was stored), but inside the level, another scripts calls the variable and I get the following error on this line:

 Debug.Log('Player Name: ' + mpManager.PlayerName);            
     if (mpManager.CurrentMap.MapName == 'Londinum' && mpManager.enable_Lap)
     {
         newPlayer.transform.Rotate(Vector3(0,180,0));
     }

 Error: NullReferenceException: Object reference not set to an instance of an object

The Debug line retrieves a correct value from my "Do not destroy on load" super script which is here refered as to "mpManager". The value not recognized is this one: mpManager.CurrentMap.MapName.

Question: Since this thing was running ok in unity3, WTF do I need to do in order to make it run in unity4?

If you help me get the solution a paypal deposit of $20 will be delivered to your account. Thnx in advz for any answer.

Comment
Add comment · 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 SkaredCreations · Dec 24, 2014 at 01:35 PM 0
Share

Since the issue is raised for mp$$anonymous$$anager then you should post the code of that script too. Anyway it seems that mp$$anonymous$$anager or Current$$anonymous$$ap is not set at the time you call the function where the exception is raised.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Class error: BCE0019: 'xxxx' is not a member of 'Object'. 0 Answers

The name '' does not exist in the current context 2 Answers

Access to a variable inside a C# class 2 Answers

Can a class hear a broadcast message? 0 Answers

How can I use method to return custom classes (Same Class Type),How to return classes in method 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