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

GetRuntimeParent called in Awake is inconvenient. #725

Closed
majesty77 opened this issue Nov 20, 2024 · 1 comment
Closed

GetRuntimeParent called in Awake is inconvenient. #725

majesty77 opened this issue Nov 20, 2024 · 1 comment

Comments

@majesty77
Copy link

VContainer: v1.16.4

Even if autorun is set to false in Awake, GetRuntimeParent is called and the Parent is set.
This is not convenient in the following situations

// With VContainerSettings.Instance.RootLifetimeScope set.
// Assuming the autorun of the LifetimeScope Prefab for this key's address is set to false
var handle = await Addressables.LoadAssetAsync<LifetimeScope>(key);
var result = handle.Result;

// Internal Awake sets Parent to VContainerSettings.Instance.RootLifetimeScope
var instance = Instantiate(assetLoadHandle.Result); 

// I call Build with parentScope as parent at another time, but it doesn't work as intended because Parent is already set
using (LifetimeScope.EnqueueParent(parentScope)) {
    instance.Build();
}

I think it would be better if the Parent is determined at Build time, since the Parent resolution process is also performed inside Build, so I think it would be better to remove the GetRuntimeParent that is called in Awake.

@hadashiA
Copy link
Owner

hadashiA commented Dec 1, 2024

You may be right.
I've decided to remove the GetRuntimeParent call. #726
If autoRun = true, it shouldn't have any effect, so it should probably be fine.
Thanks for your help.

@hadashiA hadashiA closed this as completed Dec 1, 2024
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

No branches or pull requests

2 participants