Class DiagnosticParams
Provides numeric parameters with arbitrary names and defaults, with optional overrides for individual target build platforms.
Implements
Inherited Members
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 Analysis
Constructors
DiagnosticParams()
Default constructor
Declaration
public DiagnosticParams()
DiagnosticParams(DiagnosticParams)
Copy constructor
Declaration
public DiagnosticParams(DiagnosticParams copyFrom)
Parameters
Type | Name | Description |
---|---|---|
Diagnostic |
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 |
---|---|---|
Build |
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 |
---|---|---|
Build |
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. |
Build |
platform | Analysis target platform for which to set the value. Defaults to BuildTarget.NoTarget which sets the value for the default platform. |