Skip to content

How to be sure when the model is fully instantiated in scene? #591

Discussion options

You must be logged in to vote

You should go async instead of IEnumerator

    private async Task<bool> DownloadModelAsync(string uri)
    {
        var didLoad = await gltf.Load(uri);
        var childCount = transform.childCount;
        
        //This handles the case of already having some children before loading model
        if (childCount > initialChildCount)
        {
            GameObject modelRoot = transform.GetChild(childCount).gameObject;
            OnImportFinished(modelRoot);
        }
        return didLoad;
    }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@massimilianogaio
Comment options

Answer selected by massimilianogaio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants