Is there any circumstance when Unity creates an object instance during setup?
When I use RegisterInstance
, there's obviously an instance creat开发者_开发百科ed, but by my code.
Is there any circumstance when unity would create a registered object during setup?
No, there's nothing in the standard registration objects that would cause registered objects to be created under the hood. There's a bunch of reflection over those object's types, so the assembly will get loaded into working set at that point. Unity actually defers as much work as possible to resolve time; the build plan, for example, isn't created until the first resolve for that type.
Are you seeing a specific issue, anticipating one, or just curious? More details about your actual concern would help in answering that question.
Not that I'm aware of, but you're writing the setup code, so you can always ask Unity to resolve an instance during setup and then register that instance. However, this is something you should rarely need to do (but I have seen situations where it was appropriate).
精彩评论