Skip to content

Instantly share code, notes, and snippets.

@apkd
Last active August 7, 2017 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apkd/baf52850c1b6c4460ba790d2d56b868d to your computer and use it in GitHub Desktop.
Save apkd/baf52850c1b6c4460ba790d2d56b868d to your computer and use it in GitHub Desktop.
void OnValidate()
{
// remove non-unique and non-prefabs
ReplicablePrefabs =
ReplicablePrefabs
.Where(x => !x || x.IsPrefab())
.AppendItem(null as Replicable)
.Distinct()
.ToList();
// warn for empty names
ReplicablePrefabs
.Where(x => x).Distinct()
.Where(x => System.String.IsNullOrWhiteSpace(x.ReplicableName))
.ForEach(x => Debug.LogError($"Replicable prefab {x.name} has an invalid name."));
// warn for non-unique names
ReplicablePrefabs
.Where(x => x).Distinct()
.Where(x => ReplicablePrefabs.Where(y => y).Count(y => x.ReplicableName == y.ReplicableName) > 1)
.ForEach(x => Debug.LogError($"Replicable prefab {x.name} has a non-unique name."));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment