I'm making a 2d game for android where I want to make the background blur when a popup opens.
I have tried so many techniques.
Making two camera. Blurred main camera and changing culling mask of secondary camera to the popup layer.
Using grabpass shader in a material and adding it to the background of popup.
Capturing screenshot, blurring the texture and adding it to background of popup as sprite.
Everything doing exact what I want to do. But either they are eating FPS or taking a huge time at first time.
So is there any way or workaround which will not slow it down or lag?
Related
I am very new to unity and I'm making my first game, Snake. However, when I build and run it for android everything is very small and is hard to press. Scaling everything up works however when I press play everything is huge and some are out of the screen. Does anyone know why this is happening?
Thanks
Go to your UI canvas and to the canvas scaler, set it to "scale to screen size" and change the resolution to your prefered resolution.
canvas scaler
I couldn't find an option to send a picture to better explain what's happening. Here's a Unity Link that has the photos to explain the issue.
I've tried Camera.main.orthographicsize = 4.0f, a solid number to stay on but the Orthographic Size of the camera keeps changing it's size after resizing the window when I'm in free aspect Unity editor mode and even when I export the Unity game with 1920x1080(16:9) resolution. I want it to stay the same size when resizing the window so that the game can always fit inside the screen in any resolution when resizing the window. The default blue background of the camera displays when I stretch the window's width far enough which I don't want to happen.
This Youtube video has the results I'm looking for but the code unfortunately is not working on Unity 2019. The code provided from this video does entirely different things for me and doesn't solve my issue.
From what I understood is that the screen has to has a fixed resolution.
This link will demonstrate the solution. https://docs.unity3d.com/Manual/GameView.html
It does that by changing the
Game View Aspect from free to a fixed resolution.
Unless this is not what you are looking for then I sugest another solution:
Make a black background image that fits the screen size.
Then change the scale of the objects in the scene relative to the camera.
This link will make the scaling solution, Make object visual size constant despite the distance
I am making a simple 2D Unity Game for Android, and in there I have some text in a canvas that overlays the game play which serves as a heads up display. I've noticed when the text is triggered to change the game has a significant frame rate drop, it looks like a stutter when playing. Why is such a simple task is so demanding, and more importantly how can I get around this?
When you use the new Unity UI System this kind of task becomes much more fluid and dosent stutter or lag anymore. I can recomend you to switch to the new ui system instead of rendering text without it
Im developing a game like "bubble-bobble". So far I have done physics and collision detection.
Now I want to make my Hero (Rectangle Sprite) animated. I would be glad if someone could explain simple scripting for simple animated characters or some nice links for animation.
The XNA Documentation includes an entire article on Animating a Sprite. The basic technique is to use an AnimatedTexture class, which is included within the Animated sprite sample code.
The high level idea is that you load a texture into memory using a graphics API. Since you're using C#, this is most likely done through XNA.
This texture you have loaded contains each frame of animation that is required, and may span across multiple textures. When you go and render your 'sprite' object, you pass the XNA API the texture you want to use, and a source rectangle coordinates that surround the specific frame of animation you want within that texture.
It's up to you to manage this process. I create tools that assemble these source rectangles and stores meta data about each specific animation each sprite has; like which rectangles, and the duration of each frame, etc.
So I've been trying to wrap my head around shaders in 2D in XNA.
http://msdn.microsoft.com/en-us/library/bb313868(v=xnagamestudio.31).aspx
This link above stated that I needed to use SpriteSortMode.Immediate, which is a problem for me because I have developed a parallax system that relies on deferred rendering (SpriteSortMode.BackToFront).
Can someone explain to me the significance of SpriteSortMode in shaders, if Immediate is mandatory, anything I can do to maintain my current system, and anything else in general to help me understand this better?
In addition, my game runs off of multiple SpriteBatch.Begin()/End() calls (for drawing background, then the game, then the foreground and HUD and etc). I've noticed that the Bloom example does not work in that case, and I am guessing it has something to do with this.
In general, I've been having some trouble understanding these concepts. I know what a shader is and how it works, but I don't know how it interacts with XNA and what goes on there. I would really appreciate some enlightenment. :)
Thanks SO!
The sort mode will matter if you are attempting to do something non-trivial like render layered transparency or make use of a depth buffer. I'm going to assume you want to do something non-trivial since you want to use a pixel shader to accomplish it.
SpriteSortMode.Immediate will draw things in exactly the order of the draw calls. If you use another mode, SpriteBatch will group the draw calls to the video card by texture if it can. This is for performance reasons.
Keep in mind that every time you call SpriteBatch.Begin you are applying a new pixel shader and discarding the one previously set. (Even if the new one is just SpriteBatch's standard pixel shader that applies a Tint color.) Additionally, remember that by calling SpriteBatch.End you are telling the video card to execute all of the current SpriteBatch commands.
This means that you could potentially keep your existing sorting method, if your fancy pixel shaders are of limited scope. In other words, draw your background with one Effect and then your foreground and characters with another. Each Begin/End call to SpriteBatch can be treated separately.
If your goal is to apply one Effect (such as heat waves or bloom) to everything on the screen you have another option. You could choose to render all of your graphics onto a RenderTarget that you create instead of directly to the video card's backbuffer. If you do this, at the end of your rendering section you can call GraphicsDevice.SetRenderTarget(null) and paint your completed image to the backbuffer with a custom shader that applies to the entire scene.
I'm not one hundred percent sure on how much the sprite sorting mode effects shaders, i would think it would vary depending on what you were using the shader for.
as for bloom if you're using multiple begin and ends (which you really want to minimise if you can). you can create a render target the size of the screen, draw everything as you are now. then at the very end, take that render target back (using graphicsdevice.SetRenderTarget(null);) then draw your full screen render target (at 0,0 position) with the bloom shader, that way you will bloom the entire scene, regardless of the components of the scene using various sort modes.