Ejemplo n.º 1
0
        /// <summary>
        /// Generates avatar with the selected set of resources and displayed it in AvatarViewer scene
        /// </summary>
        protected override IEnumerator GenerateAndDisplayHead(byte[] photoBytes, PipelineType pipeline)
        {
            //Get selected resources
            AvatarResources avatarResources = GetSelectedResources();

            // generate avatar from the photo and get its code in the Result of request
            var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, "name", "description", pipeline, avatarResources);

            yield return(Await(initializeRequest));

            string avatarCode = initializeRequest.Result;

            StartCoroutine(SampleUtils.DisplayPhotoPreview(avatarCode, photoPreview));

            var calculateRequest = avatarProvider.StartAndAwaitAvatarCalculationAsync(avatarCode);

            yield return(Await(calculateRequest));

            AvatarViewer.SetSceneParams(new AvatarViewer.SceneParams()
            {
                avatarCode     = avatarCode,
                showSettings   = false,
                sceneToReturn  = SceneManager.GetActiveScene().name,
                avatarProvider = avatarProvider,
                useAnimations  = false
            });
            SceneManager.LoadScene(Scenes.GetSceneName(SceneType.AVATAR_VIEWER));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Button click handler.
        /// </summary>
        public void OnShowAvatar(string avatarCode)
        {
            var avatar = GetAvatar(avatarCode);

            if (avatar.state != GalleryAvatarState.COMPLETED)
            {
                Debug.LogErrorFormat("Avatar not ready to be opened: {0}, state: {1}", avatarCode, avatar.state);
                return;
            }

            AvatarViewer.SetSceneParams(new AvatarViewer.SceneParams()
            {
                avatarCode     = avatarCode,
                sceneToReturn  = SceneManager.GetActiveScene().name,
                avatarProvider = this.avatarProvider,
                showSettings   = true
            });
            SceneManager.LoadScene(Scenes.GetSceneName(SceneType.AVATAR_VIEWER));
        }
Ejemplo n.º 3
0
        void Start()
        {
            if (colorPicker == null)
            {
                Debug.LogWarning("Color picker is not set!");
            }
            else
            {
                colorPicker.SetOnValueChangeCallback(OnColorChange);
            }

            avatarViewer = GetComponent <AvatarViewer>();

            if (avatarViewer == null)
            {
                Debug.LogWarning("Avatar viewer reference is null");
                return;
            }

            avatarViewer.displayedHaircutChanged += OnHaircutChanged;
            avatarViewer.shaderTypeChanged       += OnShaderChanged;
        }