Created
June 6, 2013 14:34
-
-
Save mandarinx/5721966 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
#if UNITY_EDITOR | |
void SingleComponentCheck() { | |
var components = gameObject.GetComponents(this.GetType()); | |
foreach (var component in components) { | |
if (component == this) continue; | |
UnityEditor.EditorUtility.DisplayDialog("Can't add the same component multiple times!", | |
string.Format("The component {0} can't be added because {1} already contains the same component.", this.GetType(), gameObject.name), | |
"Cancel"); | |
DestroyImmediate(this); | |
} | |
} | |
protected virtual void Reset() { | |
Invoke("SingleComponentCheck",0); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment