docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class StylesApplicator

    Applies styles to UI in conjunction with the test fixtures.

    Inheritance
    object
    UITestComponent
    StylesApplicator
    Inherited Members
    UITestComponent.fixture
    UITestComponent.Initialize(AbstractUITestFixture)
    UITestComponent.Shutdown()
    UITestComponent.BeforeTest()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 VisualElement to add the styles to.

    string ussContent

    The USS content as a string.

    bool ignoreError

    Whether to ignore errors encountered during processing. Defaults to false.

    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 false.

    AfterTest()

    Cleans up StylesApplicator after each test.

    Declaration
    protected override void AfterTest()
    Overrides
    UITestComponent.AfterTest()

    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 Assets/test.uss.

    bool ignoreError

    A boolean indicating whether to ignore errors encountered during processing. Defaults to false.

    Returns
    Type Description
    StyleSheet

    A new StyleSheet instance generated from the provided content.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)