Lost functionality after renaming class to GameSession

Hello there! Everything was working perfectly until attempting to rename the class from GameStatus to GameSession. It seemed to work fine, 5 instances were renamed across 3 files, as expected, but when running the game now my blocks don’t destroy and the score text doesn’t update at all (the score still updates in the inspector however.) This is my first effort at learning any code and have spent several hours trying to sort this out myself to exercise my problem solving but I’m at the end of my rope. If anybody could point me in the right direction in terms of what I should be looking at I would be super appreciative. Screenshots below!
GameSession|682x500


Hi, renaming classes is a pain - generally just don’t do it. I think Rick advises against this though he does explain how to do this in one of his courses (not sure which one). Do you have the code in source control so you can revert?

If not, I would (if you can):

  • rename the class back
  • create a new class with the correct name
  • remove the old class from any game object in the inspector
  • re-add the new class to the relevant game object

Hope that helps,

According to your images, you were able to start your game, if you were able to do that then it has nothing to do with renaming your class but with something else entirely.

According to your console there’s an issue with the line 46 of your GameSession script, unfortunately you didn’t include it in your images, so it’s kinda hard to know what is going on, but it’s telling that something is missing.

According to the Github and your warning, you probably haven’t set in the inspector the TextMeshProUGUI variable. When you rename a class this things can happen, they break links, so you’ll have to set everything again in the inspector. If this doesn’t help you pls copy and paste your GameSession code, which is the one causing problems according to your console.

2 Likes

Hey thanks for the reply! I did include that image, but it seems it was a bit too big or something and is showing as a clickable link above the other two, when I get home I’ll see if I can investigate some of your suggestions

Holy smokes it has been solved! It was indeed resetting the links in the inspector, which I thought I had done, but I wasn’t looking thoroughly enough and my troubleshooting process wasn’t quite as structured as it seems it should be, I wasn’t going through the whole list before getting distracted by another possible avenue of attack. Thanks so much for the suggestions, feels great to have this resolved!

1 Like

Privacy & Terms