docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ContentFileFixture

    Inheritance
    object
    ContentFileFixture
    ContentFileTests
    SceneTests
    Implements
    IPrebuildSetup
    IPostBuildCleanup
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.Build.Pipeline.Tests.ContentLoad
    Assembly: Unity.ScriptableBuildPipeline.Tests.dll
    Syntax
    public abstract class ContentFileFixture : IPrebuildSetup, IPostBuildCleanup

    Constructors

    ContentFileFixture()

    Declaration
    public ContentFileFixture()

    Fields

    m_Catalog

    Declaration
    protected Catalog m_Catalog
    Field Value
    Type Description
    Catalog

    m_CatalogDir

    Declaration
    protected string m_CatalogDir
    Field Value
    Type Description
    string

    m_ContentRoot

    Declaration
    protected string m_ContentRoot
    Field Value
    Type Description
    string

    m_NS

    Declaration
    protected ContentNamespace m_NS
    Field Value
    Type Description
    ContentNamespace

    Properties

    ContentDir

    Declaration
    public virtual string ContentDir { get; }
    Property Value
    Type Description
    string

    ContentRoot

    Declaration
    protected string ContentRoot { get; }
    Property Value
    Type Description
    string

    Methods

    BuildContentLoadsAndCatalog(string, AssetBundleBuild[])

    Declaration
    protected void BuildContentLoadsAndCatalog(string outdir, AssetBundleBuild[] bundles)
    Parameters
    Type Name Description
    string outdir
    AssetBundleBuild[] bundles

    Cleanup()

    Implement this method to specify actions that should run as a post-build cleanup step.

    Declaration
    public virtual void Cleanup()

    CreateCatalog(string)

    Declaration
    public ContentFileFixture.ContentBuildCatalog CreateCatalog(string name)
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    ContentFileFixture.ContentBuildCatalog

    DefaultBuild()

    Declaration
    protected virtual void DefaultBuild()

    GetVFSFilename(string)

    Declaration
    public string GetVFSFilename(string fn)
    Parameters
    Type Name Description
    string fn
    Returns
    Type Description
    string

    LoadCatalog(string, bool)

    Declaration
    public void LoadCatalog(string name, bool mountAllArchives = true)
    Parameters
    Type Name Description
    string name
    bool mountAllArchives

    PrepareBuildLayout()

    Declaration
    protected abstract void PrepareBuildLayout()

    SetUp()

    Declaration
    [SetUp]
    public void SetUp()

    Setup()

    Implement this method to call actions automatically before the build process.

    Declaration
    public void Setup()
    Examples
      [TestFixture]
                            public class CreateSpriteTest : IPrebuildSetup
                            {
                                Texture2D m_Texture;
                                Sprite m_Sprite;
    
                                public void Setup()
                                {
                                    #if UNITY_EDITOR
                                    var spritePath = "Assets/Resources/Circle.png";
    
                                    var ti = UnityEditor.AssetImporter.GetAtPath(spritePath) as UnityEditor.TextureImporter;
    
                                    ti.textureCompression = UnityEditor.TextureImporterCompression.Uncompressed;
    
                                    ti.SaveAndReimport();
                                    #endif
                                }
    
                                [SetUp]
                                public void SetUpTest()
                                {
                                    m_Texture = Resources.Load<Texture2D>("Circle");
                                }
    
                                [Test]
                                public void WhenNullTextureIsPassed_CreateShouldReturnNullSprite()
                                {
                                    // Check with Valid Texture.
    
                                    LogAssert.Expect(LogType.Log, "Circle Sprite Created");
    
                                    Sprite.Create(m_Texture, new Rect(0, 0, m_Texture.width, m_Texture.height), new Vector2(0.5f, 0.5f));
    
                                    Debug.Log("Circle Sprite Created");
    
                                    // Check with NULL Texture. Should return NULL Sprite.
                                    m_Sprite = Sprite.Create(null, new Rect(0, 0, m_Texture.width, m_Texture.height), new Vector2(0.5f, 0.5f));
    
                                    Assert.That(m_Sprite, Is.Null, "Sprite created with null texture should be null");
                                }
                            }
    
     > **Tip**: Use `#if UNITY_EDITOR` if you want to access Editor only APIs, but the setup/cleanup is inside a **Play Mode** assembly.
    

    TearDown()

    Declaration
    [TearDown]
    public void TearDown()

    Implements

    UnityEngine.TestTools.IPrebuildSetup
    UnityEngine.TestTools.IPostBuildCleanup
    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)