Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 pennomi · May 02 at 03:56 PM · bugonguipropertydrawer

First item in inspector list is incorrect height

I created a custom property drawer like so:

 using UnityEditor;
 using UnityEngine;
 
 [CustomPropertyDrawer(typeof(DialogLine))]
 public class DialogLinePropertyDrawer : PropertyDrawer
 {
     private const int Padding = 5;
     
     
     public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
     {
         // Calculate reusable values
         var start = position.x;
         var top = position.y;
         var half = position.width / 2.0f;
         var line = EditorGUIUtility.singleLineHeight;
         
         
         // Draw fields - pass GUIContent.none to each so they are drawn without labels
         var speakerRect = new Rect(start, top, half, line);
         EditorGUI.PropertyField(speakerRect, property.FindPropertyRelative("speaker"), GUIContent.none);
 
         var clipRect = new Rect(start + half, top, half, line);
         EditorGUI.PropertyField(clipRect, property.FindPropertyRelative("clip"), GUIContent.none);
 
         var emotionRect = new Rect(start, top + line + Padding, half, line);
         EditorGUI.PropertyField(emotionRect, property.FindPropertyRelative("emotion"), GUIContent.none);
 
         var positionRect = new Rect(start + half, top + line + Padding, half, line);
         EditorGUI.PropertyField(positionRect, property.FindPropertyRelative("position"), GUIContent.none);
 
         var textRect = new Rect(start, top + (line + Padding) * 2, position.width, line * 2);
         EditorGUI.PropertyField(textRect, property.FindPropertyRelative("text"), GUIContent.none);
 
     }
     
     public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
     {
         return EditorGUIUtility.singleLineHeight * 4 + Padding * 4;
     }
 }


It works as expected, except the first item in a list of that type always displays with the incorrect height. (See the image below and how the first item renders partially behind the second one.)

alt text

Is there something wrong with my code or a workaround I can use to fix this?

screenshot.png (19.3 kB)
Comment
Add comment · Show 3
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 arjenveenhuizen · May 05 at 08:46 PM 1
Share

Unfortunately, I don't have an answer, but want to let you know that I suffer from the exact same bug on Unity 2022.1.0b16.3019 (Linux). The first entry simply always has the wrong height and renders partially behind the second one. Judging by the 160+ followers of this question I guess we are not alone...

avatar image Captain_Pineapple arjenveenhuizen · May 06 at 09:26 AM 0
Share

Followers get added automatically by the forum based on subscriptions to tags. If you add "C#" as tag you'll have 500+ followers on your question. This sadly means nothing at all.

Given that you both encounter this issue perhaps you should open an official bug report on unity.

avatar image pennomi arjenveenhuizen · May 09 at 05:41 PM 0
Share

Looks like this is a Unity bug: https://issuetracker.unity3d.com/issues/first-array-element-expansion-is-broken-for-arrays-that-use-custom-property-drawers

Supposedly it's been fixed, but the problem is still there for me.

0 Replies

· Add your reply
  • Sort: 

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

161 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

Related Questions

CustomPropertyDrawer of a Generic List. 1 Answer

Unity won't let me override the default way of drawing an array/list? 2 Answers

What does "flagsCount >= mask.m_Count" mean? 0 Answers

OnGUI mystically stopped rendering buttons and text. 1 Answer

EditorGUILayout.Foldout not working properly - results in argument exceptions 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