Scene design (color) changes after loading scene - c#

I'm trying to make an FPS game using unity, but I've come across a problem. When I load my main scene after pressing "RESTART", it somehow causes my game to change appearance. But when I start the game from the main scene, it looks perfectly fine.. I've tried disabling Post Processing but I believe that's not what's causing the issue, I've provided some pictures of what happens when I load the main scene through the GameOver scene and when I load it through the MainScene.
Scene loaded through the press of a button ------Main Scene (what it's supposed to look like)
Your help is much apreciated

Ok, so after quite a while of messing around with the settings I FINALLY figured it out. To get rid of uneven lighting between the scenes all you have to do is go to Window>Rendering>Lighting>Environment> (make sure "Auto Generate" is UNCHECKED) and click Generate lighting!!!

Related

Mecanim Animation in Unity

I am facing a problem while playing a animation which is already playing at the moment.
e.g. I am currently working on boxing fighting game in which when I punch twice, first time animation is played but second time, it doesn't restart animation.
I also tried turning off that animation if it is already running, not finding any clue regarding this problem as I'm beginner in mecanim animation.
Mecanim doesn't allow you to do this directly. A state can only be in one state at a time. Either at the end and fading out or at the start and fading in, but not both at once.
You can do a hacky workaround where you make two states with the same animation and alternate between them each time you want to play that animation. It's annoying to set up and makes it take more effort if you need to refactor, but it does work.
My Animancer plugin on the Unity Asset Store has a function specifically for this situation: CrossFadeNew will always fade the animation in from the beginning. If it's already playing it will automatically create a new state to fade in while the old one fades out. Feel free to contact me via the support email address listed on the store page and in the user manual if you have any questions about it.

How can I make an animation in Unity play just once and then switch back to another animation

I am making a 2d game in Unity, and for the main character I have created 4 animations; up, down, left, and right. To do this I just made the animation and trigger them with a line of code like this:
anim.SetBool ("movingUp", true);
which would happen when the up key is pressed. This type of animation is easy to deal with because it is not based on time, but how long the player wants the character to be in that state. I am now trying to add an animation that is triggered when the character collides with another game object. I am not sure how to make it so the animation will play just one time and then go back to the other animation. Is there a way to trigger an animation to play just once in Unity?
Generally speaking you don't have to code your own controller, Unity already has that one and here is the link to official Unity tutorials how to use it. What you need is to fire off a trigger just like you did upon collision and check has exit time on that animation in the controller. After that you just guide the state back to the animation you want it to go back to. Again, accurate and thorough tutorials are found online on the term Unity Mecanim how to or Animations in Unity or something like that.
MAke an animator controller and add the 4 animations into it. then make a transition between them with the Boolean. Are you doing this as an automatic animation without triggering it?

How to remove the icon displayed by Particle System in Unity

I have a particle system in my Unity Android project and it is working very well. I wanted it to play only once so disabled looping.
Now the problem is once the particle system has finished playing, a weird icon as below appears on the screen.
Icon Displayed by Particle System
That does not look good. I altered my coding so that as soon as the animation is played, the particle system is taken off screen. But still that icon is displayed even though for a very very short period of time.
Does anyone know how to solve this? Please help me.
Thanks in advance.
That is scene view gizmo for particle system. It will not appear in the game view.
If you still don't want it. Disable as the screenshot by clicking on the icon in the Gizmos dropdown menu.

UI Image crashes Unity on play

I am creating a 3D game in Unity.
I want to have an image slowly fill up to make the cooldown of a skill visible for the player. Fortunately the UI image can do exactly that.
Unfortunately the UI image causes the engine to crash when I click play. The generic message "Unity stopped working" shows up too.
I created it by going to GameObject>UI>Image. Then I filled in the Sprite and the main camera. I did nothing else.
Removing the Canvas, Image and EventSystem (Which spawn when creating a UI image) fixes the crash.
Am I doing something wrong? I am very new to Unity.
EDIT: It turns out something in my code IS doing something to the image. However, I never in my code specify anything towards the image. I am using GUI elements though. Could that be the problem?
EDIT2: When running the Unity Debugger it gives me the error Couldn't set project path to: C:\Users\[MYNAME]\Documents\CellGame\Assets
I don't know what this means, as everything else is able to load from my assets
EDIT3: That doesn't seem to be the problem at all. What really is the problem is a line I'm calling. I'm going to try to figure out what in that line is causing trouble.
EDIT4: It turned out that there is a problem in my code. When I start my game, for some reason it detects that my player has no health, and goes to the Game Over UI. I had set this to just be the main menu UI, and when it toggles the main menu UI it also reloads the scene. Reloading the scene caused the crash, presumably.
The problem was that my script had a bug, where it would reload the scene as soon as I pressed play. With the UI image in my scene it caused Unity to crash.
I'm not sure why it crashed.

Switching between scenes blocks unity camera

If i run a scene normally in unity 3D it looks nice, but if i switch to it from another scene the camera became blocked and crashed without giving me any error!! Am i missing something? I am working with unity pro 4.5.0 and Nyartoolkit .
Here are 2 screenshot of my two scenes:
the first screenshot is my second scene and the second one is the hierarchy of my first scene !!??
It's the same problem when switching from the first scene to the second scene or going back from the second scene to my first one. In all cases the camera became black as it is clear in first screenshot .

Categories