RequireComponent for built in components
Hello! I am curious to know if there is any way we can use RequireComponent for Unity's built in components like SpriteRenderer. So when I add SpriteRenderer, another component is added automatically or is this only possible for user defined components? Another workaround will be to listen to an event. Is there any way to know when a SpriteRenderer gets created. Maybe some event gets fired? If one of these is possible, my work will become a lot easier.
Thanks.
Answer by phil_me_up · Jan 24, 2016 at 07:38 PM
You can use RequireComponent for whatever you want. However, to do what you're suggesting you would need to access the SpriteRenderer script which isn't possible (unless that's part of the OpenSource UI stuff, in which case you can).
Your best bet is to write a new script, and have that Require a SpriteRenderer. In that components Awake call you can have it take some action (including check if the sprite renderer is actually active).
Your answer
Follow this Question
Related Questions
unity run editor function everytime I save a script 0 Answers
Webview in custom Unity Editor Window? 0 Answers
/Editor Scripts Organization with 2017.3 Assembly Definition Files 2 Answers
UIElements - Horizontal scrolling is not working in ScrollView even with ScrollViewMode.Horizontal. 0 Answers
How to add StringTable data(entries) from our script for Localization purpose. 1 Answer