¿How do a fine DragAndDrop Objects?

Hi! i wish a good day for you :smile:.

I have in my .cs code the next lines:

In my .uxml file i have this:

6145034--670982--upload_2020-7-29_2-56-27.png

up to this point, all works fine, but after in the .uss is the wrong:

it .uss style looks how this:

6145034--670994--upload_2020-7-29_2-59-35.png

So ugly, i need do somehow this:

6145034--670997--upload_2020-7-29_3-1-25.png

my final questions are:

¿this is the correct way for do a functionality of drag and drop?
¿How i can change the text/style by default of unity for fields or anything ?

Thanks a lot, save you!.

** @uDamian some example about this?**

Hi @uDamian please, i need this info :smile:, helpme

It’s a bit difficult to answer you precisely so here are some general recommendations:

  • Use the UI Toolkit Debugger (from the Window menu or from the options of each window) to identify which elements you want to affect and which styles you need to modify
  • Use display:none to remove elements you don’t want
  • Generally, our controls are not meant to be completely taken over from a functionality perspective, and some cases even styling. Consider doing you own elements from scratch (although in this case I don’t think you have a way to show an object selector all by your self).

Generally though, listen for DragPerformEvent is the way to go to handle multi window drag and drop in Unity Editor. Just make sure to call Unity - Scripting API: DragAndDrop.AcceptDrag (although in this case the ObjectField is already doing it).

@antoine-unity Hi, thanks for the response.

in order to check your response:

-I use toolkit debugger for search the class/names of the objectField for modify it, i was could modify the style, but no the internal text “None (audioClip)”, how i can do it? i was trying change it with code “refLabel.text = “Droop audio clips here” and it not works”.

-I test this option, can work if remove the label style for the text “None (audioClip)” and then i add a new label with code, if this work, i tell to you :smile:.

-Exactly, i try a lot of combinations for get some similiar field how ObjectField, but i find nothing :(, is posible how a future request doing this function some how “DropField”?.

i will wait for your response.

Thanks for your time, save you, i wish a nice day for you.

The accepted way to address specific elements is to use class selector in USS or C# to query them. If you look in the debugger, you’ll see these really long classnames with are meant to address specific subelements in our controls, like unity-object-field-display__label.

Controls usually have constants to help usage with UQuery, for example : objectField.Q<Label>(className: ObjectField.labelUssClassName)

I can’t tell if we’ll every expose everything needed to re-create an ObjectField (it’s not really something we’re looking after in our team), but the drag and drop functionality should work as expected with DragPerformEvents.

thanks!!! it explanation works perfectly, now mi object field looks how i was wanted