private void Awake()
 {
     dataEntityCollection   = Service.Get <CPDataEntityCollection>();
     imageBuilderCameraData = GetComponent <ImageBuilderCameraData>();
     dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <AvatarDetailsData> >(onAvatarDetailsDataAdded);
     pendingRenderRequests            = new Dictionary <string, RenderRequest>();
     pausedRenderRequests             = new HashSet <string>();
     otherPlayerDetailsRequestBatcher = Service.Get <OtherPlayerDetailsRequestBatcher>();
     otherPlayerDetailsRequestBatcher.ResetFirstRequestStatus();
     isLoadingAvatarPrefab = false;
     if (UseCache)
     {
         avatarImageCacher = new AvatarImageCacher();
     }
 }
Example #2
0
 private void Awake()
 {
     imageBuilderCameraData = GetComponent <ImageBuilderCameraData>();
     hideAvatar();
     useBodyColor = false;
 }
    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));
    }