选择器决定 USS 规则影响哪些元素。
USS 支持一组简单的选择器,它们类似于但并不完全相同于 CSS 中的简单选择器。简单选择器通过元素类型、USS 类、元素名称和通配符来匹配元素。
您可以将简单选择器组合成复杂选择器,或附加伪类以在特定状态下定位元素。USS 支持后代、子代和多个复杂选择器。
主题 | 描述 |
---|---|
类型选择器 | 根据元素类型匹配元素。 |
名称选择器 | 根据元素的名称匹配元素。 |
类选择器 | 匹配分配了特定 USS 类的元素。 |
通用选择器 | 匹配任何元素。 |
后代选择器 | 匹配在视觉树一个由轻量级节点组成的对象图,它保存窗口或面板中的所有元素。它定义了您使用 UI 工具包构建的每个 UI。 参见术语表中另一个元素的后代元素。 |
子选择器 | 匹配在视觉树中另一个元素的子元素。 |
多个选择器 | 选择匹配所有简单选择器的元素。 |
选择器列表 | 创建以逗号分隔的选择器列表,这些选择器共享相同的样式规则。 |
伪类 | 将伪类与选择器一起使用,以定位处于特定状态的元素。 |
选择器优先级 | 了解当多个 USS 规则定位同一元素时 USS 的优先级。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.