Unity3d script seems to work in one scene but not another - c#

I am working on a group of scenes for an opening menu (Start, Options, Exit, etc).
Right now, I have the exact same "Back" 3d Text GameObject in two of my scenes that have the same script that when clicked, uses Application.LoadLevel("Main") to return to the Main scene.
The problem is, "Back" only works in one of the scenes. It does not seem to be working in the other. They are identical (Script attached, position, name, etc.).
Any ideas what might be causing this or why this is happening?
Thanks in advance!

Fixed the problem by copying over all of the assets in the problem scene to a new scene. Now it works like a charm.

Related

Unity (new) InputSystem does respond to mouse clicks

I am building this simple game, where a bunch of fellows that I have are supposed to seek a point indicated by a mouse click. The issue is that the Editor does not seem to notice mouse clicks at runtime. I have used the exact Input Action Asset before for detecting presses of "g" button, but it seemed to have stopped working when I played with it some more sometime later. I have since removed the asset and created w new Action Assets (one that I created manually and another that I created through the Input Action component button). Neither of them works. I have no idea what is going on and I have been looking at this for several hours now. Can someone please explain what I might have done wrong?
Different functions I used to try and get the Editor to respond to my code are below. MouseClick() is the original function that I needed to run, but did not work, onFire() is my attempt at running the default one that is given if Actions Asset is isnantiated through the component.
So it turns out that the issue was that the functions are supposed to be capitalized at the start.
Have you tried using the performed event ?
Also your Fire action needs to be a button type

Unity load scene in editor playmode synchronously

Main Question
I'm trying to load a scene in the editor while in playmode and get the exact behaviour of:
SceneManager.LoadScene(ScenePath, LoadSceneMode.Single);
Except without requiring the scene to be in the build settings.
I would have expected this to work:
EditorSceneManager.LoadSceneInPlayMode(ScenePath, new UnityEngine.SceneManagement.LoadSceneParameters(LoadSceneMode.Single));
However the scene appears to load asynchronously, which I don't want for my particular use case.
Is there a way to acomplish what I'm looking for here?
Additional details (my use case and "why" I want this)
What I'm doing is creating a loader for scene sets that will additively load a bunch of scenes with different constraints on their loading behaviour (such as: load async, always reload when transitioning same->same, and other features). I have this working fine in the editor while I'm not in play mode, I have it working fine in a built player, but the last case is getting this to work while in the editor and in play mode.
The reason I need "single" loading at all is when you transition from one scene set to another and they share no common scenes. Since I can't unload every scene, I'm just skipping the unload step all together and having the first synchronously loading scene load with LoadSceneMode.Single to cause everything else to unload.
On the off chance it's relevant (I really hope not) I'm trying to do this from inside a custom editor's OnInspectorGUI call. I'm triggering it from a button press in there.
Options I'm aware of:
EditorSceneManager.OpenScene with OpenSceneMode.Single
problem: Does not work in play mode
EditorSceneManager.LoadSceneInPlayMode with LoadSceneParameters(LoadSceneMode.Single)
problem: Scene is not loaded synchronously
SceneManager.LoadScene with LoadSceneMode.Single
problem: Scene is required to be in the build settings
EditorSceneManager.LoadScene with LoadSceneMode.Single
problem: Scene is required to be in the build settings
Turns out I had a misunderstanding of what SceneManager.LoadScene(ScenePath, LoadSceneMode.Single); would even do.
A friend had pointed out the docs clearly state the load will happen within 1 frame, not actually at the call-site.
If you're facing a similar issue there are a few options. You could load async and subscribe to that callback to perform activation them. Another option is to subscribe to SceneManager.sceneLoaded and perform activation there.

How to open any specific scene when the game opens

My question is that, how can I set any scene in unity as first scene (means it will open first when the game starts).
As I started making my game in unity, instead of making main menu I made LEVEL 1, and as a result when the game opens it directly starts the game by showing level 1.
So how can I set my main menu as the first scene
To further upon Retired Ninja's comment, to set a specific default scene when the game opens, you need to set the ordering of the scenes so that the one you want to start with is first, see the picture below:
The main menu screen comes first in the list of scenes, this means it will run on startup.
More details here where it has been answered on the Unity Forums:
https://answers.unity.com/questions/44953/set-first-scene.html

Save current state of scene and load it

How do i save current scene state and load it later?
I'm making a game where you are building a bridge and then press start to run over it with a car and if you fail you have a restart button that reloads the scene from origin state(without anything built on it). However, i want the player to be able to press an "Edit" button that will go back to the state right before you pressed "start" so you can keep building on your bridge without having to rebuild the whole bridge over and over again. So, how do i do this?
If you don't want to code it yourself, you can use the PlayerPrefs of Unity. If you don't know how to use it look at the documentation (https://docs.unity3d.com/ScriptReference/PlayerPrefs.html) or you can also find tuto on Youtube, even some examples.

Button no longer working in game window, but works fine in .exe build

So last night my game was working just fine. I log on today and I change an (unrelated) sprite and now for some reason the button won't be clicked in the game window during play mode. It does however work perfectly on an .exe build.
It's just the button that both players hit to say that they are ready to play the game.
Here are the relevant pieces of code pertaining to this button. The code that makes the button the code the button calls, etc.
https://gist.github.com/robofriven/ce26f24204dc0149c793
Sorry if this has already been asked, I do a lot of searching before asking questions and thus haven't had to ask anything yet, but this one has me stumped and I can't find anything similar anywhere. Thanks in advance for any and all help!
I figured it out. Apparently it has to do with the screen resolution not set to free aspect and that tweaking how the buttons respond to mouse clicks. It's kind of a phantom mouse thing where the mouse is not really pointing where it thinks it's pointing.

Categories