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 PlutDem · Feb 01, 2015 at 04:27 PM · sorting layerssorting order

Nested sorting layers?

Hello, lets say i have an object that consist from gren sprite on the back and red on the front. And i wan to group them so sprites from one object would be rendered on top of another objects sprites. Right now i can do only this: alt text

But i want this:

alt text

Is it possible?

one.png (18.9 kB)
two.png (18.9 kB)
Comment
Add comment · Show 2
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 $$anonymous$$ · Feb 01, 2015 at 06:18 PM 0
Share

sprite renderer has sorting layers? Are you using them?

avatar image PlutDem · Feb 01, 2015 at 06:40 PM 0
Share

I tried, but it looks like they are not a solution for my problem. I would need to create a new sorting layer for the each individual set of sprites. (i mean, the number of those green-red objects is unknown)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Derek-Wong · Feb 01, 2015 at 06:30 PM

I believed that Z-index is your friend. Assuming these are some objects that you will instantiate them repeatedly:

 Public float spriteZ = 0.0f;
 
 for(int i=0;i< numbersOfPrefabsYouWant; i++){
    GameObject someObj = (GameObject)Instantiate(someObjPrefab);
    someObj.transform.position = new Vector3(someX, someY, spriteZ);
    spriteZ += 0.01f;
 }

You should also set the z-index on the Green and Red sprite, say if want red on top, red's Z should be smaller than Green's Z.

Hope it helps.

Comment
Add comment · Show 1 · 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 Derek-Wong · Feb 01, 2015 at 06:58 PM 0
Share

This really works with sorting layers and I am using this solution myself, I will show you how to do it in detail tomorrow if you still cannot do it.

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

Special sprites ordering 1 Answer

Place UI text on top of other elements in 2D 1 Answer

2d Animation not rendering in front of background sprite in spite of sorting layers 1 Answer

Rendering order approach for a 2.5D game. 2 Answers

Sorting Layer Logic Issue 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