Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by CaptainCarl · Jan 30, 2015 at 05:48 PM · spritelayers

Spriterenderer on top of canvases

I have two canvases. One with a background image and one with all overlaying elements like texts and such.

The background canvas has an order of 0, the overlay canvas of 1.

Now, I'd like to create an animating sprite on top of those canvases but I can't for the life of me get the sprite on top of the other images.

I can see the sprite being on top on the stage, but when I switch to gameview, it's gone! There are no scripts attached to the sprite. Only an animator(Which works fine when I play it).

Note:

  • My canvases have a render mode of Screen space - Overlay.

  • I've set the spriterenderer on Sorting Layer 9, order 300. Although it's the only sprite out there. layer 1 or order 1 didn't do anything different, though.

  • The other elements in the canvases are either UI texts or Images

  • All the elements in the canvases are on either BackgroundLayer or OverlayLayer

  • The canvases themselves are on the UI layer

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by rob5300 · Jan 30, 2015 at 06:18 PM

Try using different cameras, or using World space as the render mode. I am assuming here that this Sprite is in the scene, not in any canvas. I can explain using different cameras:

You can have multiple cameras in the scene, and they have a render depth which defines in what order they are drawn on screen. We can have our normal camera render the canvas's and other scene objects, we will set this up now!

We then create a new camera, in the same location (maybe as a child of the main to make them always move together). We can use the culling mask feature, where we can (by using layers) to define what this camera can see. We take the sprite and place it on separate layer and define that as all that camera can see. We also remove that layer from the main camera.

We now on the new camera, change the clear flags to not clear, so we can see the main cameras stuff. Lastly we set the depth to higher than our main camera. This makes sure it renders above the other cameras objects.

And that should of worked!! Please say if i miss-understood or it doesn't make sense!

NOTE: You may have to change the render mode of the canvas's from screen space overlay to Screen space camera, otherwise Unity renders the UI over everything, which is not what we want.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CaptainCarl · Jan 30, 2015 at 06:20 PM 0
Share

I'm using the screen space-overlay because I'm making an app. It makes sure All the texts etc. are relatively placed in their corners and won't move if the resolution of the device changes. Will this be an issue when changing render mode or camera?

avatar image CaptainCarl · Jan 30, 2015 at 06:31 PM 0
Share

Next question: Screen space - Camera seems to keep the resolution intact. I've made a second camera and only show the layer "Sprites". Excluded that one from the main Camera. And the new Camera has a "Don't clear" flag. Ive made an empty object "Spriteholder" and put that on the layer "Sprites" and put a sprite on it. I see the sprite on my stage, but yet again, not in my gameview.

avatar image rob5300 · Jan 30, 2015 at 06:54 PM 0
Share

Are you sure the sprite is in the view port of the camera? I can assume you are using Orthographic for the sprite. $$anonymous$$ake sure the sprite is inside the box shown in the inspector, and it isn't right against the camera as it has a near clipping plane too.

avatar image CaptainCarl · Jan 30, 2015 at 06:57 PM 0
Share

You've lost me. I have no idea what you mean. The second camera has Sprites as only culling mask. The sprite is on Sprites. The camera is orthographic. Can we chat in here or doesn't Unity Answers have a chat function? Edit: Here's a screenshot of my 2nd camera: http://i.imgur.com/X4eCiOu.png

avatar image CaptainCarl · Jan 30, 2015 at 07:15 PM 1
Share

Got it. Changing both camera's to Orthographic did the trick

Show more comments
avatar image
0

Answer by omaglana · Aug 25, 2018 at 12:46 PM

The above answer is corrent but one thing that is forgotten is: Go to Canvas -> Render Camera: "Select the new Camera where Culling Mask is assigned at the designated layer

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Layering issue with sprites 1 Answer

Orthello Sprite Depth inconsistent for large levels 0 Answers

GameObject With Background Covers GameObject Without Background 1 Answer

Particles not rendering on sorting layer specified with sprite-default shader 0 Answers

hi this might be a dumb question but is there a way to make one sprite have multiple layers on different parts of it? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges