Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by logan4179 · Oct 19, 2018 at 02:14 PM · inspectordeclarationheaders

Why do Inspector headers with comma-separated variable declarations cause redundant headers?

if I use the following code when declaring my variables at the top of my script:

 [Header("REFERENCE")]
 public Transform trans, camTrans = null;
 public G g = null;
 protected Rigidbody rb = null;
 protected Animator anim = null;

It creates a second "REFERENCE" header after the trans reference in my inspector: alt text ...but if I take away the comma and put both transform references on the same line or put a single-line declaration before them like this:

 [Header("REFERENCE")]
 public G g = null;
 public Transform trans, camTrans = null;
 protected Rigidbody rb = null;
 protected Animator anim = null;

It works like I want and keeps all these items together under the same header. Does anyone know if there's a way around this? I'm very strict about the organization and order of my variables and would like the transforms first, on the same line, separated by commas. Thanks!

unityq1.png (22.9 kB)
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

Answer by DavidMontoyaJD · Jul 20, 2021 at 02:02 PM

For me it was very annoying because I had several variables declared with commas:

 [Header("---------   Icons")]
 public Sprite fruit, lightingBall, give5Plinkos, make10Coins, drop15PlinkosIn10Seconds, drop20Plinkos, make20Coins, SevenTex, give2Dollars, give20Dollars, give200Dollars;


which made the editor look like this:

alt text

I noticed that if I declare the first variable alone and the rest separated by commas, Unity understands it and shows it in the right way:

 [Header("---------   Icons")]
 public Sprite fruit;
 public Sprite lightingBall, give5Plinkos, make10Coins, drop15PlinkosIn10Seconds, drop20Plinkos, make20Coins, SevenTex, give2Dollars, give20Dollars, give200Dollars;

 

alt text


capture.png (32.1 kB)
capture2.png (24.9 kB)
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

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

Related Questions

Object Instance Data Declaration without Constructors 1 Answer

Hide headers and variables in inspector from parent classes 1 Answer

Script to create instance from in inspector 2 Answers

Unity3D 3.2, MonoDevelop debugger "inspector" problems 3 Answers

How to serialize an array of classes 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