• 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 Romano · Jun 23, 2014 at 03:27 AM · particle systemscene viewsorting order

How would I write an editor extension that lets you change sorting layers and sorting order in the scene view before game is playing?

I have this code to change sorting layer and sorting order on a 3D object or a particle system:

 #pragma strict
 
 public var sortingLayerName : String = "Default";
 public var sortingOrder        : int = 0;
 
 function Start () 
 {
     renderer.sortingLayerName = sortingLayerName;
     renderer.sortingOrder      = sortingOrder;
 }

Unfortunately it only works in play mode. I'd like to be able to see the correct sorting orders while I'm designing the scene, does anyone know how to go about doing that? An editor extension or a script that I add onto game object seems like it might be the best way? I haven't been able to find anything that helps so far.

Thanks!

Romano

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 Fornoreason1000 · Jun 23, 2014 at 08:08 AM 1
Share

well that's your problem you are using Start(), Start() is only called during playtime!!!!

what you need is maybe an editor window or even just a function that sorts these layers for you. you want to check out the EditorWindow class

http://docs.unity3d.com/ScriptReference/EditorWindow.html

this here will be triggered when you select "Sort my stuff" from the dropdown menu ins$$anonymous$$d of Start() which is triggered by the first frame an object is created. (this is in c#)

 [$$anonymous$$enuItem ("Sorting/Sort my stuff")]
     static void Init () {
               //Code goes here
 
     }
 


avatar image Romano · Jun 23, 2014 at 11:51 AM 0
Share

I'm aware that Start is only called during play, sorry maybe I wasn't clear that that code is only intended for use during play and that I have no idea how to affect what the renderer does before play. Great hint about the drop down menu! I had only thought of it being automatic, not that the user could refresh the depth settings after setting them. Thanks!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by meat5000 · Jun 23, 2014 at 12:00 PM

If you are talking about the hieracrchy ordering, now being Transform ordering instead of Alphanumeric, check this thread.

http://forum.unity3d.com/threads/unity-4-5-new-hierarchy-window-sorting.248298/

There is a script in there which adds the old sorting method back in, which you can then select from a button on the hierarchy bar.

There is a new functionality listed in the docs which is apparently necessary to implement the upcoming new GUI system. This method is used to order your objects.

Comment
Add comment · Show 2 · 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 Romano · Jun 23, 2014 at 12:10 PM 0
Share

Sorry no, I mean sorting layer and sorting order like you might see on the sprite renderer, that's an interesting read though, I had wondered why things suddenly aren't alphabetical :)

avatar image meat5000 ♦ · Jun 23, 2014 at 12:23 PM 1
Share

Fair play :) I'll leave this here then, even though it doesn't answer your question.

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

23 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 avatar image avatar image

Related Questions

why does unity crash when putting prefab in hierarchy while in scene view 0 Answers

How to change partcile system's order in layer through script? 1 Answer

Separate particle systems rendered together with a single sorting mode? 0 Answers

Sudden green rings on particles. Only visible in Scene view 1 Answer

GPU Sorting 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