/// <summary> /// Initializes avatar provider and requests available resources /// </summary> protected override IEnumerator Initialize() { GameObject providerContainerGameObject = GameObject.Find("AvatarProviderContainer"); if (providerContainerGameObject != null) { avatarProvider = providerContainerGameObject.GetComponent <AvatarProviderContainer>().avatarProvider; } else { // Initialization of the IAvatarProvider may take some time. // We don't want to initialize it each time when the Gallery scene is loaded. // So we store IAvatarProvider instance in the object that will not destroyed during navigation between the scenes (ResourceSmaple -> ModelViewer -> ResourceSample). providerContainerGameObject = new GameObject("AvatarProviderContainer"); DontDestroyOnLoad(providerContainerGameObject); AvatarProviderContainer providerContainer = providerContainerGameObject.AddComponent <AvatarProviderContainer>(); avatarProvider = AvatarSdkMgr.IoCContainer.Create <IAvatarProvider>(); providerContainer.avatarProvider = avatarProvider; var initializeRequest = avatarProvider.InitializeAsync(); yield return(Await(initializeRequest)); if (initializeRequest.IsError) { Debug.LogError("Avatar provider was not initialized!"); yield break; } } yield return(UpdateResources()); }
private IEnumerator Initialize() { // First of all, initialize the SDK. This sample shows how to provide user-defined implementations for // the interfaces if needed. If you don't need to override the default behavior, just pass null instead. if (!AvatarSdkMgr.IsInitialized) { AvatarSdkMgr.Init( stringMgr: stringManager, storage: persistentStorage, sdkType: sdkType ); } GameObject providerContainerGameObject = GameObject.Find("AvatarProviderContainer"); if (providerContainerGameObject != null) { avatarProvider = providerContainerGameObject.GetComponent <AvatarProviderContainer>().avatarProvider; } else { // Initialization of the IAvatarProvider may take some time. // We don't want to initialize it each time when the Gallery scene is loaded. // So we store IAvatarProvider instance in the object that will not destroyed during navigation between the scenes (Gallery -> ModelViewer -> Gallery). providerContainerGameObject = new GameObject("AvatarProviderContainer"); DontDestroyOnLoad(providerContainerGameObject); AvatarProviderContainer providerContainer = providerContainerGameObject.AddComponent <AvatarProviderContainer>(); avatarProvider = AvatarSdkMgr.IoCContainer.Create <IAvatarProvider>(); providerContainer.avatarProvider = avatarProvider; var initializeRequest = InitializeAvatarProviderAsync(); yield return(Await(initializeRequest, null)); if (initializeRequest.IsError) { Debug.LogError("Avatar provider isn't initialized!"); yield break; } } yield return(UpdateAvatarList()); // disable generation buttons until avatar provider initializes foreach (var button in galleryControls.GetComponentsInChildren <Button>(false)) { if (button.name.Contains("Generate")) { button.interactable = true; } } }