• 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
1
Question by Lava444 · Jun 22 at 01:29 AM · arrayinspectoreditor-scripting

First array element in inspector rendering below other elements.

I was following Sebastian Lague's procedural planet generation series from a while back. I was on episode 3 and I ran into some weird inspector rendering. There was a public array and the first element always rendered below the others like this: https://drive.google.com/file/d/1KIC3Dti-uCAwZO_pV3wk2UM75DBvl58s/view?usp=sharing. It only happens with the first item. The rest work fine.

Here's the github page I was referencing to write the code: https://github.com/SebLague/Procedural-Planets/tree/master/Procedural%20Planet%20E03/Assets

Comment
Add comment · Show 1
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 breban1 · Jun 23 at 06:05 PM 0
Share

I was JUST about to post this same question!

I am using Unity 2020.3.36f1 LTS (YES, it's an LTS version!) This wasn't happening in 2020.3.33f1, but I don't know if it was something I changed after upgrading from 33f1->36f1.

It's my own script having the problem.

https://i.ibb.co/d6GLSM0/unity-editor-bug.png

     [System.Serializable]
     public struct AnimStruct
     {
         public string name;
         public int startFrame, endFrame;
         public float speed;
         public bool looping;
         public Action<GameObject> callback;
     }

2 Replies

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

Answer by breban1 · Jun 23 at 06:28 PM

Looks like this is a known issue according to the community: https://issuetracker.unity3d.com/issues/first-array-element-expansion-is-broken-for-arrays-that-use-custom-property-drawers

However, there is a workaround by using [NonReorderable] on your array. You won't be able to reorder it, but at least it can be edited. (Noted by KWIKDEV on the link above - thank you!)

     [NonReorderable] public AnimStruct[] anims;

Not a solution, but at least you can continue development.

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 Lava444 · Jun 24 at 01:26 PM 0
Share

Oh that's cool. I didn't know about the property workaround. I don't really need to reorder my array so I'll try that. Thanks.

avatar image
0

Answer by TheSalmonn · Jun 23 at 06:57 AM

If anything, I'd say this is an issue with the version of Unity you're using. If it's not an LTS, bugs tend to pop up more frequently. It might be the safest bet to download the latest LTS so as to avoid bugs like these, especially if you're using an alpha or beta version of Unity.

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 Lava444 · Jun 23 at 05:21 PM 0
Share

I'm using version 2021.3.3f1. I don't know if there have been any reports of arrays doing weird stuff in the inspector. It could be a problem with the editor scripting in the github page, but I'm not too knowledgeable about that stuff. https://github.com/SebLague/Procedural-Planets/blob/master/Procedural%20Planet%20E03/Assets/Editor/PlanetEditor.cs

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

168 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 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

How can I recreate the Array Inspector element for a custom Inspector GUI? 7 Answers

Editor scripting: Object reference not set to an instance of an object 0 Answers

Display custom names for array 1 Answer

How to get notification of moving a GameObject in the hierachy when editing the scene? 1 Answer

Edit Static Class Config variables from editor 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