Overflow behavior of DisplayAsString

Issue #136 resolved
Johannes P. created an issue

When using the DisplayAsString attribute, by default the displayed content will overflow onto the next line when the inspector is not wide enough to display its content.

It would be useful to have the option to have the overflow be hidden, similar to how Labels already behave, for example DisplayAsString(overflow: false);


An example use-case would be using a DisplayAsString Property in a HorizontalGroup to display dynamic information in a compact way:

// Control
[PropertyOrder(0)]
public string AVeryVeryVeryLongStringLabel = "Test";

// Example
[PropertyOrder(1)]
[HideLabel, DisplayAsString]
[HorizontalGroup("Demo")]
[ShowInInspector]
private string LeftLabel
{
    get { return "A Very Very Very Long String Label " + Time.frameCount; }
    set { }
}
[PropertyOrder(2)]
[HideLabel]
[HorizontalGroup("Demo")]
public string RightString = "Test";

DisplayAsStringExample.gif

Ignoring how contrived this example is, I have had a few instances where I was using DisplayAsString on a string and I wanted to ensure that the inspector would not grow in height unexpectedly.

It may be enough to change the default behavior of DisplayAsString specifically for string fields/properties.

Comments (5)

  1. Bjarke Elias
    • changed status to open

    Noted, and added to our todo list.

    We could introduce various parameters where you could specify whether you wanted the text to clip, overflow or word-wrap, support rich-text, font-size etc... The attribute could use some love.

    I'm guessing that the example is just a simple setup to showcase the issue cleanly (thanks!). But thought I would mention it just in case: For this particular example you could just use the You could use the [LabelText("$LeftLabel")] attribute.

  2. Johannes P. reporter

    Oh neat, I was actually not aware that you could use string tokens. What would that be referred to as in the documentation? The LabelText docs don't mention it, so I'm assuming it's either a new feature, or more general? Would be useful to throw that into a few of the examples in the docs, at least with a 'see also' link on tags that support it.

  3. mSkull001

    We've implemented the option to enable or disable DisplayAsString overflow, which will be available in a new patch soon.

    display-as-string-overflow.png

  4. Log in to comment