hadashiA / VContainer

The extra fast, minimum code size, GC-free DI (Dependency Injection) library running on Unity Game Engine.
https://vcontainer.hadashikick.jp
MIT License
2.02k stars 176 forks source link

Proposal: IFocusable for OnApplicationFocus(). #678

Open maxgmer opened 5 months ago

maxgmer commented 5 months ago

I use the approach you recommended with MonoBehaviors used for views, while plain C# scripts being controllers for views.

I have a problem with a task, where I should update view (in this case view is an external script I cannot change) when application focus changes.

Can you add an interface like "IFocusable", similar to other interfaces outlined here? https://vcontainer.hadashikick.jp/integrations/entrypoint (void OnApplicationFocus() of MonoBehavior).

This would greatly simplify this use-case without having to add additional "event hook" MonoBehaviors.

lsw1164 commented 5 months ago

agree!

stenyin commented 1 month ago

Adding an IFocusable might be unnecessary. You can use Application.focusChanged directly in Initialize to handle focus changes without extra interfaces.