Hi all,
So, I’m wanting to do something a bit complex (at least I think it is). For starters, I’m not entirely sure it’s even possible, but here we go.
I’m wanting to set up a custom attribute for variables of different types, ranging from ints to arrays, and while this isn’t the hard part, I want to set up a behavior to do stuff with those variables. This is the part I’m not sure about.
Like…
I have a couple of custom attributes that I attach to class members (fields, properties and methods) for development purposes (in editor only). One allows me to watch their current value in the inspector and another allows me to perform commands/tweak values from the inspector.
I’m not really certain what I want to do with them just yet. It’s more for the sake of curiosity. I suppose for now just being able to write a method that will gather all the variables that have a specified attribute in the same script would be more than enough (I say that like it’s simple. No idea if it is or not)
I once used them in a game client as a sort of poor-man’s ORM. The client would call a server to read data and the attribs told the service call manager where to stash the results of the query. If you’re using them with any frequency, you should always plan to cache the references to attrib-tagged elements. Attributes work via Reflection which has a reputation for poor performance (often well-deserved, but not always).