My game doesn’t seem to play the scenes in the correct order - unity3d

But my scenes don’t go in order and I’ve tried disabling some scenes and it skips scene 1 and 3 but when I disable some of the other scene like 4,5,6 it still skips 1 and plays 2,3 and like it skips scenes and I don’t know what to do and I couldn’t find anything on YouTube I might of disabled something in setting but I don’t know since I’ve only been at it nearly a month
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1)
and
SceneManager.LoadSceene(1)

The order of BuitIndex is defined in build Window.
To get that one go to File->Build Settings menu or press Ctrl+Shift+B In the window that pops-up, you can see all scenes that you have added to build. If you don't see your current scene, there is a button on the lower left that says Add Open Scenes. And in here, you can click-&-drag the scenes in list, to change their build index.
Hope this helps

Related

Lag when exporting functionality into a block in Scratch

I'm new to scratch.
I have this code within a sprite, which works as expected without noticeable lags:
But, when I "export" the flickering into the 'flicker' block, it has a very nasty lag:
I created a special sprite in order to easily "feel" the lag, with this code:
This ball smoothly moves, until (every 5 seconds) there is the flickering effect and it stops for 1 second or so.
Can anyone give me a clue why it happens, and how to prevent it?
The project page is here.
Any assistance would be appreciated.
Let me start by pointing out that the problem does not occur when I launch your project.
I tried it in 5 different web browsers on 3 different devices with 2 different operating systems, and every time, the ball just kept moving.
However, I can make such an issue happen by enabling 'Run without screen refresh' in the 'flicker' block, as follows:
Right-click on the red 'define flicker' block.
From the context menu, select 'Edit'.
In the 'make a block' dialog, turn on checkbox 'Run without screen refresh', then click OK.
I suspect 'Run without screen refresh' claims all processing power, effectively blocking any other (concurrent) scripts.
My guess is, you already fixed the problem yourself by turning off 'Run without screen refresh'.
In general, 'Run without screen refresh' is a great way to reduce lag in scripts where speed is essential. But never use it in a script with 'wait' or 'forever' blocks, or it will cause lag.

Why is the play button on my title screen not starting the game?

I managed to open the demo game that I need to see/play, however, it looks like the title screen isn't loading correctly. Clicking on the "Play" button should allow the user to start the game, but when I try clicking on it, nothing happens.
I'm not sure why this is happening because I downloaded the exact same files as the ones that were used in the demo and I also tried deleting/redownloading the files a couple of times. I also double checked the console messages and there aren't any errors/warnings for any scripts. I'll attach a screenshot of what I see and the link to the game files themselves if anyone wants to try it on their end.
Also, if this helps, I'm using Unity version 2018.3.2f1.
Here is a link to the project if you want to try it out yourself (I'd post the code, but I don't want to put a giant block of code up without a clear direction; however, I believe the main menu content is in the "Manager.cs" file): https://drive.google.com/file/d/1ekXt948b612dmyT1AZReUOuzh2XbnSDG/view?usp=sharing
This is what the game looks like if it helps:
After reading through the code in the other scripts, I realized that the error was coming from the specific region that was being used as a "hitbox" on the screen for the play button. And because I was setting my aspect ratio differently than what the developer used, the positioning of the "hitbox" did not line up correctly on my screen. So instead, I had to change the aspect ratio to fixed resolution and specific canvas sizes (width and length).

Save data from game to editor? [duplicate]

Apparently this is some beginner's question (and that I am) but it's driving me crazy and I couldn't find any mention:
I Occasionally forget to exit Play mode and go on building my UI making objects and changes, only to realize that I'm still in Play Mode and as soon as I unpress the play button, these will be purged! I suppose the Unity Editor has its reasons for allowing editing of Scripts/Scenes while in Play Mode (would be happy to hear some examples-maybe testing scenes?) but my main question here is:
Is there some way for me to prevent this behavior? Or at least some trick that you use to prevent me from making changes while in play mode? (Other than becoming paranoid about it and checking constantly...)
Thank you
PS. sigh time to head back to Unity and rebuild that UI that I lost...
Other Unity coders have had this problem before me and they came up with a neat solution.
Setting the UI to a different colour while in playmode "Playmode tint".
You can read the details here (originally posted 2009 but I have checked it still works in latest Unity 5.3):
http://answers.unity3d.com/questions/9159/best-strategies-for-not-accidently-editing-whilst.html
There is no settings to prevent changing things during play mode but there are ways to reduce the chances of losing changes during play mode.
1.Edit->Preferences... -> Colors. Now, on the right change Playmode Tint to red. That will remind you you are making changes in play mode.
2.Click on the gear icon of each component you change during play then click Copy Component. When are done with playmode, select the component you want to keep its changes. Click the gear icon again and this time, Click Paste Component Values.
3.Write an Editor Plugin that will do that for you. This is hard but possible.
Use event to find out when entering playmode. Store all GameObject public important variables such as transform/rigidbody properties in a list.
Wait for the stop event to fire then ask your self which GameObjects to overwrite settings to. Then overwrite the properties of the selected GameObjects That's it.
Usefull APIs for this:
EditorApplication.isPlaying
EditorApplication.isPaused
EditorApplication.isPlayingOrWillChangePlaymode
EditorApplication.playmodeStateChanged += callBackFunc;
EditorApplication.HierarchyWindowItemCallback
EditorApplication.ProjectWindowItemCallback
Note: According to Unity roadmap, a feature that enables you to save playtime changes is in construction and will be released soon but the above seems to be the only way at this time.
You can select objects you want to keep while in play mode, copy them with Ctrl + C, and then just paste them back in with Ctrl + V after returning to edit mode. Then you can eithr delete the originals from the scene or copy values from individual components like #Programmer suggested.

Unity3d editor: how to prevent changes from being undone upon exiting play mode?

Apparently this is some beginner's question (and that I am) but it's driving me crazy and I couldn't find any mention:
I Occasionally forget to exit Play mode and go on building my UI making objects and changes, only to realize that I'm still in Play Mode and as soon as I unpress the play button, these will be purged! I suppose the Unity Editor has its reasons for allowing editing of Scripts/Scenes while in Play Mode (would be happy to hear some examples-maybe testing scenes?) but my main question here is:
Is there some way for me to prevent this behavior? Or at least some trick that you use to prevent me from making changes while in play mode? (Other than becoming paranoid about it and checking constantly...)
Thank you
PS. sigh time to head back to Unity and rebuild that UI that I lost...
Other Unity coders have had this problem before me and they came up with a neat solution.
Setting the UI to a different colour while in playmode "Playmode tint".
You can read the details here (originally posted 2009 but I have checked it still works in latest Unity 5.3):
http://answers.unity3d.com/questions/9159/best-strategies-for-not-accidently-editing-whilst.html
There is no settings to prevent changing things during play mode but there are ways to reduce the chances of losing changes during play mode.
1.Edit->Preferences... -> Colors. Now, on the right change Playmode Tint to red. That will remind you you are making changes in play mode.
2.Click on the gear icon of each component you change during play then click Copy Component. When are done with playmode, select the component you want to keep its changes. Click the gear icon again and this time, Click Paste Component Values.
3.Write an Editor Plugin that will do that for you. This is hard but possible.
Use event to find out when entering playmode. Store all GameObject public important variables such as transform/rigidbody properties in a list.
Wait for the stop event to fire then ask your self which GameObjects to overwrite settings to. Then overwrite the properties of the selected GameObjects That's it.
Usefull APIs for this:
EditorApplication.isPlaying
EditorApplication.isPaused
EditorApplication.isPlayingOrWillChangePlaymode
EditorApplication.playmodeStateChanged += callBackFunc;
EditorApplication.HierarchyWindowItemCallback
EditorApplication.ProjectWindowItemCallback
Note: According to Unity roadmap, a feature that enables you to save playtime changes is in construction and will be released soon but the above seems to be the only way at this time.
You can select objects you want to keep while in play mode, copy them with Ctrl + C, and then just paste them back in with Ctrl + V after returning to edit mode. Then you can eithr delete the originals from the scene or copy values from individual components like #Programmer suggested.

Unity Interface select on Click in Scene View

Unity won't let me select objects on my scene without first selecting the object in the Hierarchy. This was all I could find on the issue.
However, it seems that they decided that closing and opening the scene window fixed the bug, but not so with me. Also note that I am on a blank project. Its been really difficult to work around this bug.
Edit:
I have even uninstalled Unity and reinstalled with the hopes that this would solve the problem, but unfortunately it did not. Thanks for any help ahead of time.
Honestly this is such an odd problem that I'm having difficulty knowing how to try and fix the problem. I also reported the bug as recommended below by NoëlWidmer, but even the staff who was very kind had no idea how to deal with the problem, and the advice he gave also didn't change a thing. Truly, I don't even know what more information I can give you guys because as I said I literally opened a new Unity project for the first time after reinstalling and was unable to select without first clicking on the hierarchy. Is this just a special freak case that landed with me or has this happened to anyone else?? Also I'm using a two year old Windows 8 Laptop with literally nothing installed on it but the Adobe suite and a few other game developer necessities, so my computer most likely is not the source of the problem.
Edit: a Clue??
Well I was messing around with the scene and hierarchy view in full screen, and I noticed something interesting after clicking on the object in the hierarchy and moving the object in the scene view:
Unfortunately my PrintScreen doesnt show the actual mouse, but as you can see the scene view acts as though I'm clicking on the object, but here at the same time I saw my real mouse off down to the right! Also while I've selected an object on the scene editor and I move my mouse off the scene window things get a bit off and the mouse will pop up on other sides of the window and so on. I don't know if that's normal and its that way for everyone or if it's just me and it might help figure out what's going on.
Man I've really been liking Unity but if this keeps up I think I'll have to drop it and find another software, because I certainly will never be able to design anything worth while if I have to select the object on the hierarchy every time for every single object.
Some bug for me on Mac platform. I resolve just entering and exit from fullscreen mode.
Probably may also work change layout with top-right combo.
I had similar issue while using older versions of unity (in addition inspector window lost the focus repeatedly). In my case rearraging editor windows and saving custom window layout solved it. As far as I remember, I just moved scene view outside Unity window (on the second screen) as well as hierarchy view, and saved resulting position as a new window layout.
Not sure if there is anything else I can tell about it, it's pretty mysterious problem.
I'm overwhelmed with joy right now!! The problem was indeed a bug. I was working on a project and moving objects around (still using the hierarchy to select objects) and then a split second later for absolutely no reason Unity decided to start working the way it should've!!! I guess its just one of those issues where you just have to cross your fingers and hope it'll resolve itself. I'm so glad this dumb issue resolved itself because I was about to tear my hair out and succumb to using another computer for my unity design, or even worse another software. Thank you to everyone who helped!