Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for onDettached onAttach UnityWidget #729

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

Ortes
Copy link
Contributor

@Ortes Ortes commented Dec 13, 2022

Add support for onDettached onAttach UnityWidget to help setup and dispose Unity without loading a new scene

Description

I use the attached boolean in the FlutterUnityWidgetController to know if it is the the corresponding Widget is attached.
When a UnityWidget is build it handles calling onAttached and onDetached on the Widgets which changed attached state.
The last controller added in UnityPlayerUtils.controllers will be the one to be displayed (which correspond to the last one built).

I needed to change lib/src/io/mobile_unity_widget_controller.dart MobileUnityWidgetController._() constructor because the stream was not initialized before the event was sent so it was not caught.
Only Android is supported for now.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@juicycleff
Copy link
Owner

This looks handy but I think we could rework the api to match the new stream api for next release #733

@Ortes
Copy link
Contributor Author

Ortes commented Dec 18, 2022

Yes I think this is a good idea I will rebase this on #733

@Ortes Ortes force-pushed the support-for-on-detached-on-attached branch from ac66ba0 to c0173b6 Compare January 9, 2023 20:32
@Ortes Ortes force-pushed the support-for-on-detached-on-attached branch from 021d538 to 0ddbba2 Compare February 21, 2023 09:25
@timbotimbo timbotimbo mentioned this pull request May 7, 2023
7 tasks
@timbotimbo
Copy link
Collaborator

I introduced a small merge conflict by merging the null-safe example.
It should only be the api_screen.dart file, and you can just keep all your current changes.
So keep all the FlutterUnityController. calls instead of the 'newer' _unityWidgetController?. calls.

@timbotimbo
Copy link
Collaborator

@RoyalCoder88
Even though you've approved this, don't merge this before #733 is done. It contains commits (and new bugs) from that branch.

@RoyalCoder88
Copy link
Collaborator

@RoyalCoder88 Even though you've approved this, don't merge this before #733 is done. It contains commits (and new bugs) from that branch.

Okey just let me know when it's ready I will test it properly, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants