- Home /
Question by
Ragueel · Jul 30, 2020 at 06:23 AM ·
c#monobehaviourattribute
How to create custom attribute for auto injecting monobehaviour?
I have a lot of dynamically created objects which have some scripts in it. They have behavior fields which they need to do some game logic. I was thinking of automating the process of setting these fields with a custom attribute which will look like [AutoInject] private T _property;
Basically what it does is FindObjectOfType<T>()
and then assigns it. How can I create this custom attribute?
Comment
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I call function in inhereted script? 1 Answer
"Restart " C# script that has [ExecuteInEditMode] attribute and Start() function. 0 Answers
Question about classes on C# 1 Answer