Method ValidateAsset
ValidateAsset(string)
Checks whether the asset located at a path is valid for this asset reference. An asset is valid if it is of the correct type or if one of its sub-assets are.
Declaration
public override bool ValidateAsset(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The file path to the asset in question. |
Returns
Type | Description |
---|---|
bool | Whether the referenced asset is valid. |
Overrides
Remarks
The asset can be either a SpriteAtlas or a Sprite.
Examples
The example below uses ValidateAsset to check if an asset at a specific path can be set.
public bool IsPathValid()
{
string guid = AssetDatabase.AssetPathToGUID("Assets/Sprites/oldSprite.png");
AssetReferenceSprite assetRef = new AssetReferenceSprite(guid);
return assetRef.ValidateAsset("Assets/Sprites/newSprite.png");
}