Unity-Technologies / UIElementsExamples

Unity project containing examples to use UIElements in the Editor
435 stars 66 forks source link

Some questions #12

Open Scorr opened 7 years ago

Scorr commented 7 years ago
  1. Is it possible to enter pseudo-states from code? Docs only mention that they're not extensible. Use case is entering "hover" when any element of the container is hovered, instead of only the container(background) itself.
  2. Is adding our own controls going to be more extensible? Seems controls are backed by an internal "VisualElementAsset", that decides how the control will be displayed. Right now it appears the way to create a custom button control is to add an Image and a Label, but would be nice if we could create our own VisualElementAssets.
  3. Not really a question but the new readme update (28f9b91) is invite-only.

EDIT: Just realized 3 might not be intended to be public yet, so disregard that.

mathieum-unity commented 7 years ago

Hi Scorr,

  1. PseudoStates are currently for internal use only. In the future, some of them could be exposed as properties. The behavior you described was fixed in 2017.2: When a leaf element is hovered, the entire container parenting chain is flagged as hovered. If you need this for styling purposes, a current workaround would be to catch mouse move events with a RegisterCallback() , set a custom css class to your elements using VisualElement.AddToClassList("MyHoveredWorkaround") and use a css selector on "MyHoveredWorkaround" instead of the :hover selector.

  2. A VisualElementAsset allows the instantiation of VisualElement hierarchy from an xml description. Creating custom VisualElementAssets is not currently supported in 2017.2. We are currently working on improvements to this workflow and Uxml support for custom VisualElements will be greatly simplified in 2017.3. Stay tuned!

  3. Please have a look at the previous versions: 2017.2: https://docs.google.com/document/d/19MzE8uTK_UjtYZkrrb7oMuNHF_nFpjBPdBIvgMBRNew/edit 2017.1: https://docs.google.com/document/d/1ZmtPhJqridaJuzoMJUtBlDq26uHHopdF8M1v6H9McTo/edit#heading=h.9kkpbg5kzeeq

Scorr commented 7 years ago

Thanks for answering.

Hover does flag the entire chain in 2017.2. However it seems that focus does not (have not tested other pseudo-states). Could you confirm if this is intended behaviour?

Thanks for the workaround suggestion! I'm trying to use it for focus due to the above, but it does not seem to take order into account. Thus:

.test:hover {
    background-color: #FFFFFF;
}

.testFocus {
    background-color: #000000;
}

Will result in :hover always taking precedence over .testFocus, regardless of the order in the .uss.

When trying to make .testFocus override .test:hover it seems the same workaround is needed for hover, using a .testHover and AddToClassList. Shouldn't it order overrides in order of appearance in the .uss?

AGeorgy commented 6 years ago

Hi all, could you solve my misunderstanding please. I tried to make:

.scrollView.verticalScroller.slider.dragElement
{
    width:25;

    slice-top:22;
    slice-bottom:22;

    background-image:resource("Images/Knob Vertical");
}

But it doesn't work. How to change view of scrollView elements?