Beispiel #1
0
        public static IEnumerator RenderOutfit(DCustomOutfit outfit, Color beakColor, Color bodyColor, Color bellyColor, ImageBuilderCameraData cameraData, GameObject avatarGO, Func <ModelRenderer, bool> onProcessModel, AvatarAnimationFrame animationFrame = null)
        {
            AvatarModel avatarModel = avatarGO.GetComponent <AvatarModel>();

            avatarModel.BeakColor  = beakColor;
            avatarModel.BodyColor  = bodyColor;
            avatarModel.BellyColor = bellyColor;
            avatarModel.ClearAllEquipment();
            avatarModel.ApplyOutfit(outfit);
            AvatarView avatarView = avatarGO.GetComponent <AvatarView>();

            yield return(new WaitUntil(() => avatarView.IsReady));

            ModelRendererConfig renderConfig = new ModelRendererConfig(avatarGO.transform, cameraData.ModelOffset, new Vector2(cameraData.IconSize, cameraData.IconSize));

            avatarGO.transform.Rotate(cameraData.ModelRotation);
            renderConfig.FieldOfView = cameraData.FieldOfView;
            ModelRenderer modelRenderer = new ModelRenderer(renderConfig);

            modelRenderer.RotateCamera(cameraData.CameraRotation);
            if (animationFrame != null)
            {
                Animator component = avatarGO.GetComponent <Animator>();
                component.Play(animationFrame.StateName, animationFrame.Layer, animationFrame.Time);
            }
            do
            {
                yield return(null);
            }while (onProcessModel(modelRenderer));
        }
        protected override IEnumerator processRequest(RenderParams renderParam)
        {
            ItemRenderParams param = renderParam as ItemRenderParams;

            if (penguinPreload != LoadingTriState.FAILURE)
            {
                Color bodyColor = ((param.bodyColor != Color.clear) ? param.bodyColor : defaultBodyColor);
                penguin.transform.localPosition = new Vector3(10f, 0f, 0f);
                avatarModel.ClearAllEquipment();
                try
                {
                    avatarModel.ApplyOutfit(createOutfit(param.equipment));
                }
                catch (Exception ex)
                {
                    Log.LogErrorFormatted(this, "When applying an outfit to the avatar model an error occurred. Icon not rendered. Message: {0}", ex);
                    yield break;
                }
                avatarModel.BeakColor  = bodyColor;
                avatarModel.BellyColor = bodyColor;
                avatarModel.BodyColor  = bodyColor;
                while (!avatarView.IsReady)
                {
                    yield return(null);
                }
                LightCullingMaskHelper.SetLayerIncludingChildren(penguin.transform, "IconRender");
                modifyMaterials(bodyColor);
                yield return(renderToTexture(param));
            }
        }