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.
Related
When I attempt to build my project, the renderer renders only the UI and none of the actual 3D content of the game. In addition, when any animation takes place, afterimages form where the UI changes. Here are a couple images of what is expected to happen and what actually happens.
Expected:
expected menu screen
expected menu screen 2
Actual:
buggy menu screen
We are using URP and we are attempting to deploy on WebGL. We saw that others solved this issue when they turned off the skybox. However, when we tried to do this, it did not solve the problem. Please let us know what additional information is needed and if you've had this problem before. Thank you.
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!!!
I want to put a scene in Unity into virtual reality using Google Cardboard.
I used to be able to just drag a CardboardMain prefab into the scene, delete the main camera, use CardboardMain as the camera position, and CardboardHead to track where the user was looking.
After reading the release notes for the new updates, I thought I could drag a GVREditorEmulator and GVRControllerMain into the scene, and keep the normal camera.
Unfortunately, I can't figure out how to get the camera to follow my character with this new setup. (In this case, a rolling ball.)
If I change the position of the normal camera, it looks like it works fine in Unity, but as soon as I upload it to my phone, the user stays in the same place, while the ball rolls away. (The user can still control the ball's movements, but the camera/user doesn't follow the ball at all.)
I had thought that the chase cam demo would be useful, but that's only for Daydream, and I'm using Cardboard.
This trick seemed to work for some people. I tried in on a previous version of Unity and a previous version of the SDK and it did not seem to work. I may just need to try it on this new version, but I'm worried about going into the released code and editing it, so I'd prefer answers that don't require this.
Is there any way I can get the user to move in a Google Cardboard scene in Unity when I upload it to my iPhone?
UPDATE:
It looks as though my main camera object is not moving, making me think that something is resetting it back to the center every time, lending some more credence to the "trick" earlier. I will now try "the trick" to see if it works.
UPDATE: It doesn't look like the lines listed in the "trick" are there anymore, and the ones that are similar in the new program don't even seem to be running. Still trying to figure out what continues to reset the main camera's position.
UPDATE: Just got a response back from Google on GitHub (or at least someone working on the SDK) that says "You just need to make the node that follows the player a parent of the camera, not the same game object as the camera." I'm not exactly sure what that means, so if someone could explain that, that would most likely solve my problem. If I figure it out on my own I'll post back here.
UPDATE: Zarko Ristic posted an answer that explained what this was, but unfortunately the tracking is still off. I found out how to get Google Cardboard to work with the old SDK and posted an answer on that. Still looking for ways to get the new SDK to follow a character properly.
You can't change positioin of camera in cardboard application, position of MainCamera it always must be 0,0,0. But you can just simply made empty GameObject and make it parent of MainCamera. In Cardboard games actualy you can move parent of camera instead MainCamera directly.
Add script for tracking ball to MainCamera parent (GameObject).
This does not answer my question, but is a solution to the problem.
Do not use the newest version of the SDK. Use version 0.6
When building the app in Unity, do not select to have VR enabled under the build settings. (VR will still be enabled in the app.) (Credit: Zarko Ristic)
When putting the app onto your phone, if XCode prompts you to change any settings, you can ignore it.
In addition, disable bitcode under "Build Settings -> Enable Bitcode -> No" (Currently, this will not allow you to put your app onto the app store. I would greatly appreciate it if anyone has information on how to get it to run without doing this.)
Now your app should run on your phone correctly.
Just finished a small game project and have uploaded the complete project via WebGL, however currently the game loads the first scene and crashes trying to load the main scene, there are no errors in the compiler and it works perfectly in the editor.
I'm not sure if this is just for me, so could someone try the game, it freezes(audio still playing) when you click play in the main menu.
http://www.willcardoso.co.uk/UnityGameBuilds/Mario/Completed/index.html
I believe that maybe it could be because the file size may be too big for google? Maximum Used Total Memory = 190mb. If this is the issue, any help on slimming down the file?
My game is crashing whenever I switch scenes and then press play in the editor. I am using this code to switch scenes:
...
I have tried disabling most of the scripts in my game to debug the problem but it freezes every time. I've also tried loading the levels without the co-routines but that doesn't help. I can continue playing the game as long as I don't use the editor controls, however things get pretty choppy and performance becomes terrible.
First, look at the editor logs, quite possible that the reason of the crash will be there. If unsure, post them here (post on gist and link here).
Also, if you have unity pro (or a trial version of pro), try looking at the profiler's readings. On free you can also try looking at the Stats button from the Game window. Using too much memory (RAM or VRAM) can cause crashes.
i was also having same problem. if your program is correct then just change the editor path to anything in unity hub and save, close unity hub, open again and set the path to previous one.