The ability to tag scripts

Hello,
I have a scenario where I have a script called eye.js which has functions like canSee(), isInViewingRange(), etc. and the script is attached to each eye of a character. Then, I have a script called ear.js, which has functions like canHear(), isListening(), etc. and is attached to each ear of a character. Then, I have a script called brain.js that is attached to the head of a character along with many other scripts that are also attached, such as guard.js, civilian.js, thief.js that contains actions that tell the skeletons of each character how to move according to the functions provided in those scripts. The brain script gathers information from eye.js and ear.js, and depending on what the character THINKS he is, brain.js sends that information to the other scripts attached to the head.

Suppose I have more than one script for a character that thinks he’s a guard. Wouldn’t it be nice to be able to apply tags to those scripts and write a script that will tell all the scripts with a certain tag to enable, and the other scripts to disable?

You could use attributes to do this. They’re already supported (definitely in C#, and I think in JS as well).

You create a custom class deriving from Attribute, and apply it to your scripts using [AttributeNotation] in C# or @AttributeNotation in JS. Then in your brain component, you’d GetComponents() to get all components attached to the object; then, for each component, use Attribute.IsDefined(component.GetType(), typeof(MyTagComponent)) to see whether the attribute is applied to that component’s script or not.