Skip to content

Instantly share code, notes, and snippets.

View acoppes's full-sized avatar

Ariel Coppes acoppes

View GitHub Profile
@acoppes
acoppes / TypeValidationAttribute.cs
Created December 30, 2022 19:57
Useful to validate if references to Object or GameObject match specific type in Unity
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class)]
public class TypeValidationAttribute : PropertyAttribute
{
public Type typeToValidate;
public TypeValidationAttribute(Type typeToValidate)
{
this.typeToValidate = typeToValidate;
}
}
public class RandomAnimalNameGeneratorService : MonoBehaviour
{
[FormerlySerializedAs("colorsTextAsset")]
public TextAsset firstNameTextAsset;
[FormerlySerializedAs("adjectivesTextAsset")]
public TextAsset secondNameTextAsset;
[FormerlySerializedAs("namesTextAsset")]
public TextAsset thirdNameTextAsset;