docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class DiagnosticParams

    Provides numeric parameters with arbitrary names and defaults, with optional overrides for individual target build platforms.

    Inheritance
    object
    DiagnosticParams
    Implements
    ISerializationCallbackReceiver
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.ProjectAuditor.Editor
    Assembly: Unity.ProjectAuditor.Editor.dll
    Syntax
    [Serializable]
    public sealed class DiagnosticParams : ISerializationCallbackReceiver
    Remarks

    When deciding whether to report a diagnostic issue, some Analyzers need to compare a value extracted from the project with an arbitrary threshold value: For example, when reporting that the project contains textures larger than some specified size. DiagnosticParams are saved in the ProjectAuditorSettings asset, which should be included in the project's version control repository. By default, every AnalysisParams is constructed with a copy of the global DiagnosticParams for use during analysis. Individual parameters can be overridden on different platforms (for example, to set different texture size thresholds on different target platforms). DiagnosticParams will return the parameter value that corresponds to the target platform, or the default parameter if there is no override for the platform.

    Constructors

    DiagnosticParams()

    Default constructor

    Declaration
    public DiagnosticParams()

    DiagnosticParams(DiagnosticParams)

    Copy constructor

    Declaration
    public DiagnosticParams(DiagnosticParams copyFrom)
    Parameters
    Type Name Description
    DiagnosticParams copyFrom

    The DiagnosticParams object to copy from.

    Methods

    DoGUI(BuildTargetGroup)

    Draw project settings GUI for a specific BuildTargetGroup.

    Declaration
    public void DoGUI(BuildTargetGroup btg)
    Parameters
    Type Name Description
    BuildTargetGroup btg

    The BuildTargetGroup to draw the project settings UI for.

    GetDefault(string)

    Get the default value for this parameter.

    Declaration
    public int GetDefault(string paramKey)
    Parameters
    Type Name Description
    string paramKey

    Parameter key to look up.

    Returns
    Type Description
    int

    The default value for the key if it can be found, or 0 if not.

    GetParameter(string)

    Get the value of a named parameter. The parameter must have previously been registered with the RegisterParameter method.

    Declaration
    public int GetParameter(string paramName)
    Parameters
    Type Name Description
    string paramName

    Parameter name to look up.

    Returns
    Type Description
    int

    The parameter value for the currently-set analysis platform.

    GetTooltip(string)

    Get the tooltip for this parameter.

    Declaration
    public string GetTooltip(string paramKey)
    Parameters
    Type Name Description
    string paramKey

    Parameter key to look up.

    Returns
    Type Description
    string

    The tooltip if the paramKey can be found, or null if not.

    GetUserFriendlyName(string)

    Get the user friendly name for this parameter.

    Declaration
    public string GetUserFriendlyName(string paramKey)
    Parameters
    Type Name Description
    string paramKey

    Parameter key to look up.

    Returns
    Type Description
    string

    The user friendly name if the paramKey can be found, or the paramKey itself if not.

    OnAfterDeserialize()

    Unity calls this method automatically after serialization.

    Declaration
    public void OnAfterDeserialize()

    OnBeforeSerialize()

    Unity calls this method automatically before serialization.

    Declaration
    public void OnBeforeSerialize()

    RegisterParameter(string, string, string, int)

    Register a parameter by declaring its name and default value. Parameters are registered on the "default" platform, so are available for retrieval on every target platform.

    Declaration
    public void RegisterParameter(string paramName, string userFriendlyName, string tooltip, int defaultValue)
    Parameters
    Type Name Description
    string paramName

    Parameter name.

    string userFriendlyName

    A user friendly name to show in project settings.

    string tooltip

    Text to show on a tooltip in project settings.

    int defaultValue

    The default value this parameter will have, unless it has already been register.

    SetAnalysisPlatform(BuildTarget)

    Sets the target analysis platform. When retrieving parameters, DiagnosticParams will first check the values specific to this platform.

    Declaration
    public void SetAnalysisPlatform(BuildTarget platform)
    Parameters
    Type Name Description
    BuildTarget platform

    Target platform for analysis.

    SetParameter(string, string, string, int, BuildTargetGroup)

    Set the value of a named parameter for a given analysis platform.

    Declaration
    public void SetParameter(string paramName, string userFriendlyName, string tooltip, int value, BuildTargetGroup platform = BuildTargetGroup.Unknown)
    Parameters
    Type Name Description
    string paramName

    Parameter name to set.

    string userFriendlyName

    A user friendly name to show in project settings.

    string tooltip

    Text to show on a tooltip in project settings.

    int value

    Value to set the parameter to.

    BuildTargetGroup platform

    Analysis target platform for which to set the value. Defaults to BuildTarget.NoTarget which sets the value for the default platform.

    Implements

    ISerializationCallbackReceiver
    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)