Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: label rewriter #5

Open
tenpn opened this issue May 20, 2013 · 2 comments
Open

Idea: label rewriter #5

tenpn opened this issue May 20, 2013 · 2 comments

Comments

@tenpn
Copy link
Owner

tenpn commented May 20, 2013

Override the default label (maybe every drawer should provide this?):

[CustomLabel("Distance (m)", "Distance in meters to target")]
public float m_distance;

Maybe a secondary option that just adds a tooltip?

[CustomTooltip("Distance in meters to target")]
public float m_distance;
@tenpn
Copy link
Owner Author

tenpn commented May 20, 2013

for this we need a generic default property renderer, as calling EditorGUI.PropertyField() results in a stack overflow (!). Could make it available to all.

@Crushy
Copy link

Crushy commented Oct 6, 2013

I have implemented a CustomLaber property drawer recently using this helper function:

void DrawDefaultProperty(Rect position, SerializedProperty property, GUIContent label,bool includeChildren = true)  {

        //Horrible hack because just doing EditorGUI.PropertyField crashes
        Dictionary<string, PropertyDrawer> s_dictionary =
        typeof(PropertyDrawer).GetField("s_PropertyDrawers", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null) as Dictionary<string, PropertyDrawer>;

        foreach (var entry in s_dictionary) {
            if (entry.Value == this)  {
                s_dictionary[entry.Key] = null;
                EditorGUI.PropertyField(position, property, label, true);
                s_dictionary[entry.Key] = this;
                return;

            }

        }

        EditorGUI.PropertyField(position, property, label, true);

Based on a workaround I found online. I would submit a patch but this is a really hideous thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants