Class StylesApplicator
Applies styles to UI in conjunction with the test fixtures.
Inherited Members
Namespace: UnityEditor.UIElements.TestFramework
Assembly: Unity.UI.TestFramework.Editor.dll
Syntax
public class StylesApplicator : UITestComponent
Methods
AddStylesToElement(VisualElement, string, bool)
Creates a new style sheet from the given ussContent and adds it to the visual element.
Added styles will be removed during TearDown.
Declaration
public void AddStylesToElement(VisualElement element, string ussContent, bool ignoreError = false)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | element | The |
| string | ussContent | The USS content as a string. |
| bool | ignoreError | Whether to ignore errors encountered during processing. Defaults to |
AddStylesToRoot(string, bool)
Creates a new style sheet from the given ussContent and adds it to the root visual element. Added styles will be removed during TearDown.
Declaration
public void AddStylesToRoot(string ussContent, bool ignoreError = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ussContent | The USS content as a string. |
| bool | ignoreError | Whether to ignore errors encountered during processing. Defaults to |
AfterTest()
Cleans up StylesApplicator after each test.
Declaration
protected override void AfterTest()
Overrides
CreateStyleSheetFromString(string, string, bool)
Creates a new StyleSheet instance from a string containing USS content.
Declaration
public static StyleSheet CreateStyleSheetFromString(string contents, string fakePath = "Assets/test.uss", bool ignoreError = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contents | The USS content as a string. |
| string | fakePath | The fake path used internally to mimic a real asset location. By default, this is |
| bool | ignoreError | A boolean indicating whether to ignore errors encountered during processing.
Defaults to |
Returns
| Type | Description |
|---|---|
| StyleSheet | A new |