Other projects launch and play perfectly fine but with this one 2d game, when I try to enter play mode, it keeps loading forever

Whenever I try to enter play mode for this one game it won’t ever load in, but it also won’t freeze, stop, or not respond. Again I am able to launch and play/test other games.

(It wont let me attach the game as a zip :expressionless: )

Hello, is this a game you yourself coded or someone else? An eternal loading is usually due to a loop that is infinite (eg)

int treesSpawned = 0;

if(treesSpawned < 10){
 Instantiate(treePrefab, transform.position, transform.localEulerAngle);
}
//The above code loops because the original int value (treesSpawned) is always 1 it is never increased
if(treesSpawned < 10){
 Instantiate(treePrefab, transform.position, transform.localEulerAngle);
 treesSpawned++;
}
//Above code will stop and not loop infinitely as each time the tree spawns it adds 1 to the count of treesSpawned meaning that it will get to ten and stop

I used spawning trees just as a random example of a loop that could be infinite, it could be a coroutine that never stops etc.

I made this myself and as far as I know, it just decided to stop working one day, ie. I didn’t change anything. Also I don’t think I have any procedural generations like that.

Okay, the more info you give the better I can assist. So a for loop or (check against variable) does not always mean procedural generation, double check all your loops, coroutines etc. Ensure all do have an end condition. Have you upgraded the project from an earlier version of Unity (2022 to Unity6 for example)

I will check on the scripts tomorrow, however I can’t upgrade versions because this is for a school assignment. I don’t know why, but we have to use this version.

Dont worry about upgrading versions etc, I can easily work with any version, just need to check scripts

Most likely spinning into an infinite loop.

Check the editor.log for details, eg this will contain any logs that you can’t see in the Console yet because the editor is busy trying to enter playmode.

Using the debugger may help you narrow down the issue. You can halt execution with a breakpoint and step through code, primarily focus on any loops that could possibly run infinitely.

Divide and conquer strategy may also help. Simply disable all game objects in the scene root for a first test to see if enter playmode works (regardless of errors). Then you can enable them one by one until you found the one that causes an infinite loop. This narrows down which scripts to look at.

Ok so I did check my scripts and I didn’t find any crazy loops, and also I don’t think it is an issue with the scripts because I hadn’t changed anything before it stopped working…

I would love to attach the scripts so you could scan them for yourselves in case I missed anything but it says “Sorry, new users can not upload attachments.” not sure what that means since I’ve been using unity for like 5 years now but whatever. If you have any other Ideas that will allow me to send y’all files or even the game, let me know.

On the odd case where the editor gets stuck due to a problem with cached data you could try closing the editor and delete the Library folder. After deletion is complete, try again. Sometimes this helps fix the odd issue.

Sorry, I don’t know what the library folder is

It’s the Library folder that sits just inside the root folder of your project.

It’s a temporary cache and can safely be deleted. It will be regenerated when the project is opened.

Hey guys, just gonna say that I was instructed to just remake the game entirely, which is when I then discovered that it was the version that was buggy for whatever reason. I am going to see if I can build it in a different version.
So as of now I won’t really require more help but if you want to continue to suggest help I will gladly try.

  • I already re-installed unity hub and all installations
  • did firewall and permission things

(by the way I was away for a week so that’s why I stopped replying)