Problems with packages

posted to: Space Shooter Setup

Hi,

I've been working on the Space Shooter lessons. I started with the original course that used unity 4.6. That caused a problem because there is a lot of differences in the C# script. Unity tried correctly what I had input, but there were too many errors.  I figured I would downloaded the mobile version of the project, get updated scripts in that. But I am getting these errors....

NullReferenceException: Object reference not set to an instance of an object
GameManager.Start () (at Assets/MobileSpaceShooter/Scripts/GameManager.cs:54)

That line referencing this line ...

     scoreText = scoreText.GetComponent<Text> ();

Now, I think it is related to the UI element ...

public Text scoreText;

I've done some research and it looks like an error that you get when you haven't put something in the inspector correctly. But when you select the GameManager in the assest, the section for scoreText won't allow you to drag any GameObject into the window. 

In the mobile version, there is a  ....

       public GameObject scoreText;

But it is commented out. I tried messing around with that but that just created more error. 

I think I am close to an answer but I am missing something. It seems like the scoreText.GetComponent<Text> line isn't working. 

I've imported the entire package from the first and last unity package that was included in the downloads. Both have the same errors. 

Below is a screenshot of unity . You can see that I have filled in the inspector but those at the bottom, Score text that is listed a None(text). That seems to be the problem. I have been chasing this problem around for too long by myself and need a second opinion. 

Thanks 


  • Jonathan Gonzalez(jgonzalez) replied

    The original project files use an older TextMesh component and in the course it is replaced with UI text. I'll take a look at the files again to see what the issue could be. It might be best just to remove all the older TextMesh components altogether and just leave in the UI based text to avoid conflicts. 

  • Jonathan Gonzalez(jgonzalez) replied

    Ok so I looked through the packages. It's a bit tough since each lesson is meant to be followed with the scene. So the Game Manager is going to have empty slots since usually they will be filled by the end of the lesson. I did modify the first starting scene so it has everything from the PC based shooter ready to go.

     I had the UI elements in the script but I commented them out. I also commented out the UI variables and uncommented the original game object text. All the scenes after that go over modifying the game manager to account for the new UI changes. The final scene, 05_FinalGame, includes the completed mobile game with everything assigned. All the lessons before it will require some input on your end to fill something in that was taught in that specific lesson.  I will be uploading the new project files that have the PC based version of the project files for the first scene. I recommend importing that scene alone into your project to avoid issues. 

  • Jonathan Gonzalez(jgonzalez) replied

    Ok project files have been uploaded again with the new changes made to the first scene. If you continue to have issues let me know and I'll do my best to help you out. The first scene is the final game from the original PC based Space Shooter. The final scene, 05_FinalGame, is the final game for the mobile space shooter. So you should see 2 variations of the game within the project files. 

  • mleonard17 replied

    Hi,

    Thanks for getting back to me so quickly on this. My goal was to do the PC game course and then work on the mobile course. But because of the version changes, I keep getting errors. It was a bit of a nightmare. The original course was 4.6, I think. I had 5.3. The mobile course was done in 5.5, so I couldn't use that scene at first. I had to upgrade. Yeah, unfortunately, its a little more complicated than working with different versions of blender. 

    As for the final version, 05_FinalGame , I tried that one. I might have missed a step. This is what I did. I couldn't bring the files straight into Unity as a project. I had to import as custom package. I made sure that everything in custom package was included. When it came in, it was just stuff in the assets folder and I had to rebuild it. I pulled things into the Hierarchy( the game manager prefab), then I started to assign stuff in the inspector panel on the prefabs. I'm pretty sure I checked all the boxes, and applied the changes to the prefabs. Did I miss anything?

    Any advice would be appreciated. Thanks again for getting back to me so quickly. 

  • mleonard17 replied

    Great, Thanks!

  • mleonard17 replied

    Hi,

    I downloaded the new version. Works perfectly. I think what was happening was a version issue. On import, the prefabs didn't have anything listed in the inspector. On this version it did. I thought I filled all the blanks. It is going to frustrate me for awhile, because I know it was something probably simple that I overlooked. Thanks again for the new version, and I look forward to working through the mobile course. 

    Thanks