• 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 peterworth · Mar 04, 2014 at 02:41 PM · 2dparticlestextmesh

non-sprite GameObjects in 2d games

I'm using a lot of particle effects and text mesh objects in my 2d game, and laying them out in the editor is incredibly awkward, because they will always appear behind any sprites in the scene (one of which is the BG image and covers the whole scene).

I'm able to bring them to the correct layer in-game with a script like this on each of them:

 var sortingLayerName : String;
 var sortingOrder : int;

 function Start () {
     var someRenderer : Renderer = this.renderer;
     someRenderer.sortingLayerName = sortingLayerName;
     someRenderer.sortingOrder = sortingOrder;
 }

but this doesn't affect what i can see in the editor.

Are there any workarounds for this? Or is it something that needs to be fixed in unity? (quite urgently in my opinion!)

Thanks for any help.

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 Dblfstr · Mar 04, 2014 at 02:53 PM

This seems obvious, so forgive me if you have tried this. Bur if you are working in 2D mode (working in the X-Y plane). Try adjusting your objects location in the Z direction. Because when you add object to your scene, often times the Z location is seemingly random, so you objects could literally be behind your sprites. I keep all of my 2D stuff at certain Z coordinates depending on what they are supposed to do. I also like to use increments of 5. So my normal stuff is all a Z=0; but intermediate background is at Z= -5, and background is at z= -10, Buttons and stuff are at Z = 5, or Z = 10, depending on their function. You can easily adjust this buy changing to 3D mode to situate your gameobjects.

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 peterworth · Mar 04, 2014 at 03:15 PM 0
Share

Yes, tried that! Thanks though.

The z location doesn't seem to do anything in this situation, maybe it is somehow overidden by the sprite sorting layers system

avatar image Dblfstr · Mar 04, 2014 at 03:18 PM 0
Share

Figured. But I do not use rendering layers. I use physics layers, for collisions. I control my rendering via the Z axis. So I am not sure how render layers will affect the outcome.

avatar image peterworth · Mar 04, 2014 at 03:20 PM 0
Share

So i should just not use the sorting layers at all? Is it possible to do this with sprites, and just have the z deter$$anonymous$$e order?

avatar image Dblfstr · Mar 04, 2014 at 03:20 PM 0
Share

Do you have multiple cameras? This can affect what is shown as well. I do sometimes keep a camera for GUI stuff and a camera for the game stuff. Have to make sure to check the camera depth and culling to display everything properly.

avatar image peterworth · Mar 04, 2014 at 03:39 PM 1
Share

for anyone else's future reference - just put all sprites onto the "default" sorting layer in order to use the z position to deter$$anonymous$$e order ins$$anonymous$$d

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 People are following this question.

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

Related Questions

Particles - start speed curve doesn't work? 1 Answer

How to put a particle system on each of Text Mesh Pro characters? 0 Answers

Make TextMeshPro text appear over sprite? 1 Answer

Particles system animation 0 Answers

Why does my particle child not keep its vertical position? 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