Last active
August 7, 2017 16:35
-
-
Save apkd/baf52850c1b6c4460ba790d2d56b868d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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