Sprite not displaying - unity3d

I'm facing a problem in my scene i drop a object ball in hierarchy and arrange its position in center. But it's not showing that ball in Scene and Game tab it only shows its circle collider radius like this:
But when I untick and then tick again back to a component sprite renderer then it's show that object in Scene and Game tab like this:

Check your material. Possibly this material have selected not-existed shader.
Check Sorting layer. It must be higher than background Sorting layer

Related

Unity GameObject rendering below GameObject lower in the hierarchy

I have a GameObject (TopSquare) that is rendered after PlayButton in the hierarchy, yet the PlayButton is showing on top. This goes against Unity's rule of objects added last are shown over objects added previously.
Why is this?
The square is a sprite that is an object in the World, while the button exists in the UI layer over it.
You have to use UI Image for black square instead of sprite renderer (Right-click on parent -> UI -> Image)

How do I get the 2d sprite gameObject in front of the UI Canvas?

hierarchy
2d sprite
panel UI
in game
Fist make sure your canvas' Render Mode is not set to Screen Space - Overlay.
If it is, then switch it to Screen Space - Camera and then change its Render Camera property to point to your main camera.
You can then use the following canvas' properties to control where it appears in relation to other sprites (which appears on top of which), the same way you control any other 2D Sprite:
Sorting Layer
Order in Layer
Also worth noting that 2D Sprites with same Sorting Layer and Order in Layer will use the distance to the camera to decide which one appears on top of which, and the same is true for the canvas:
If your canvas' Render Mode is set to Screen Space - Camera, it will always be positioned in front of your camera and you need to use its Plane Distance property in order to position it correctly.
If your canvas' Render Mode is set to World Space, you can position it freely in the world in the same way you position any other sprite.
First of all the hierarchy window in unity is completely irrelevant when its about positioning.
In Unity everything is 3D, even if you switch to 2D perspective.
So in your case you still have your camera, your sprite and your canvas in a 3D Dimension.
To set your sprite in front of the canvas you only need to increase the positioning stats (seen in your "panel UI" screenshot) at least slightly closer to your camera than the canvas is.

How to apply a shader on multiple sprites' rendering in Unity3D?

In Unity3d, I'm trying to make a simple metaball effect using multiple sprites of a blurred round, and those sprites move randomly.
Thus I'd like the shader to perform a pixel color change from the rendering of all the sprites all together and not one by one.
Here is an example :
The picture on the left shows four sprites with the blurred sprite ; the picture on the right is the result of the shader.
And I have no clue of how to do this.
If I understand your question correctly, what you can do is
Create a new RenderTexture
Move these sprites off-screen, out of the main camera's view.
Point a new orthographic camera at all of the sprites that you've moved off-screen and set this camera's Target Texture field (in the Inspector view) to the render texture. This will save whatever the camera is seeing to that texture.
From here you can render that texture onto the surface of another game object (maybe a Quad?)
Attach a custom shader material to that quad that takes the render texture as input.
Perform whatever operations you wish to the render texture within this shader
Position this quad object in front of your main camera so that the final result gets rendered to screen
Does this make sense?

How can i make the second camera to display in the bottom right corner in a small window only specific gameobject?

I added a new layer called it: CameraLayer.
I have one Camera as child under the first ThirdPersonController tagged as MainCamera. I set that this camera will show everything but the CameraLayer. In the inspector in Culling Mask. Everything marked but not the CameraLayer. And now i see in the Culling Mask: Mixed. This is the main camera showing everything.
The second camera i added as child under a Cube. And i want that this camera will show only the cube all the time in a small window in the bottom right corner in the Game View window while the game is running.
In this camera Culling Mask i selected only the CameraLayer and unselected the rest. So in this camera in the Culling Mask i see: CameraLayer.
But when i'm running the game i don't see the Camera under the Cube at all.
In the screenshot i marked in black where should the Camera under the Cube should be and display the Cube:
1) Create a Canvas as child of your first Camera then create a RawImage as a child of this newly created Canvas.
This is this Image that will render your second camera video so move it at the bottom right of the view of your first camera.
2) Then Create a RenderTexture and assign it to the Texture property of the RawImage you just created
3) And finally assign this RenderTexture to the Target Texture property of your second Camera.
This Target Texture will be used by Unity as a buffer Texture for your Camera. Your scene should now look like this:

Unity coordinates doesn't work

I'm very beginner in Unity so please forgive if, this questions isn't so hard to answer:)
So, I have a text on a Canvas in the editor, it is okay, it's showing well on Scene editor and In Game as well.
But, when I added two Sprites, which going to be the player and the enemy, the positions of these sprites are behave a bit weird.
The text position is: x: -293 y: 195, when I'm modifying the position of the text it works fine.
When I add the sprites to x:0 y:0 and x:1 y:1, in the scene editor they appear in the left bottom corner, but when I check in the game, they placed in the middle of the screen.
My question is why the coordinates and the positions are so different on Scene (grey) and on Game (blue) ?
Because initialized render mode of Canvas in Unity is "ScreenSpace - Overlay". So it is shown on too big area in scene. If you want to work only in view field of camera, in inspector just change render mode of Canvas to "ScreenSpace-Camera" and drag your MainCamera to RenderCamera in inspector. Even if you use ScreenSpace-Camera, coordinate system of RectTransform (UI Objects transform) is different than Transform (Normal game objects transform)
in this view, if you get closer to the left-down corner of your scene, you will see your main camera area and Sprites that are in correct positions.
I hope this helps.