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
0
Question by zboyet · Jul 17, 2014 at 10:04 PM · 2dspriterenderersorting layers

Need more flexible sorting layers

I am creating an 2D tile system that basically uses voxels to store tile information. A chunk holds tile and layer information. Each chunk in the z axis is a new "world layer" (my own term) like underground or the second story of a house. My problem comes from the fact I want to just define the chunk layers in unity like ground, foliage, walls etc. Then have the world layers dealt with at runtime so everything on a higher world layer renders above the lower. From what I can tell changing the unity layers at runtime is not possible and adding layers by hand for each possible world layer is just silly.

I could use z depth to determine what is visible but that would mean throwing away the sprite renderer and I really don't want to do that. Looking into Material.renderQueue seems promising but I am not sure exactly how it works and its relationship with with sortin layer.

This one has me a bit stumped and I am not sure if it is even feasible to use the sprite renderer here.

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

1 Reply

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

Answer by Pyrian · Jul 17, 2014 at 10:40 PM

You can use Z-values and the camera's Z-value to exclude Sprites from rendering just fine. It won't control the order they render - you need SortingLayer for that - but it can prevent them from rendering at all.

So, if you use SortingLayer/SortingOrder and corresponding Z-values to design your world, you can scroll "down" in it by setting the camera's Z-value.

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 zboyet · Jul 17, 2014 at 11:10 PM 0
Share

If I am understanding you correctly that would mean that I could no longer show more than one world layer at a time. I would like to show the second story of a building for instance.

avatar image Pyrian · Jul 17, 2014 at 11:22 PM 0
Share

No, you just don't see anything "above" your camera. You can still see multiple z-values deep, if you want. You can even cap that depth in the camera settings (it defaults to 1000).

avatar image zboyet · Jul 17, 2014 at 11:48 PM 0
Share

Hmmm maybe I am just being thick but I am not seeing how this solves the issue. It seems a sprite with a higher sorting layer will always be on top of the lower no matter the z value. Only when the sorting layers are the same will the z value be taken into account. When I stack groups of layers (my world layers) I can set the z value of the chunk but it only matters on the matching layers. So even if I place a piece of foliage on a lower chunk it will always be above the ground of a higher chunk. Hiding chunks on a world layer I dont need is trivial but it does not really help when I need to display multiple chunk layers.

avatar image Pyrian · Jul 18, 2014 at 02:55 AM 0
Share

Then I don't think I understand your problem at all. You can set what appears on top of what, and you can set what doesn't appear at all. What is it that you cannot figure out how to do?

avatar image Pyrian · Jul 18, 2014 at 03:26 AM 0
Share

Would it help if I mentioned that you can change what order Sprites are rendered in (i.e. which ones are on top) during runtime by editing renderer.SortingOrder (and/or renderer.SortingLayer and/or renderer.SortingLayerID)?

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

[2D] [C#] Sprite disappears after changing position 1 Answer

Render particles in front of any sort layer (2D sprites) 3 Answers

Unity 5: MeshRenderer and SortingLayer not working? 6 Answers

Why do my GameObjects have a flickering line above them? 2 Answers

Why do my hinge joints 2d not work when they are first loaded? 1 Answer


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