| | 1 | | using DCL; |
| | 2 | | using System; |
| | 3 | | using UnityEngine; |
| | 4 | | using Object = UnityEngine.Object; |
| | 5 | |
|
| | 6 | | namespace MainScripts.DCL.Controllers.HUD.CharacterPreview |
| | 7 | | { |
| | 8 | | public class CharacterPreviewFactory : ICharacterPreviewFactory |
| | 9 | | { |
| 1 | 10 | | private static readonly Vector3 COORDS_TO_START = new (0, 50, 0); |
| 1 | 11 | | private static readonly Vector3 VECTOR_BETWEEN_INSTANCES = new (3, 0, 3); |
| | 12 | |
|
| | 13 | | private int controllersCount; |
| | 14 | |
|
| | 15 | | private CharacterPreviewController prefab; |
| | 16 | |
|
| | 17 | | public ICharacterPreviewController Create( |
| | 18 | | CharacterPreviewMode loadingMode, |
| | 19 | | RenderTexture renderTexture, |
| | 20 | | bool isVisible, |
| | 21 | | PreviewCameraFocus previewCameraFocus = PreviewCameraFocus.DefaultEditing, |
| | 22 | | bool isAvatarShadowActive = false) |
| | 23 | | { |
| 0 | 24 | | var instance = Object.Instantiate(prefab); |
| 0 | 25 | | instance.transform.position = COORDS_TO_START + (VECTOR_BETWEEN_INSTANCES * controllersCount); |
| | 26 | |
|
| 0 | 27 | | var characterPreviewController = instance.gameObject.GetComponent<CharacterPreviewController>(); |
| | 28 | |
|
| 0 | 29 | | characterPreviewController.Initialize(loadingMode, renderTexture, new PreviewCameraController()); |
| 0 | 30 | | characterPreviewController.SetEnabled(isVisible); |
| 0 | 31 | | characterPreviewController.SetCharacterShadowActive(isAvatarShadowActive); |
| 0 | 32 | | characterPreviewController.SetFocus(previewCameraFocus, false); |
| | 33 | |
|
| 0 | 34 | | controllersCount++; |
| | 35 | |
|
| 0 | 36 | | return characterPreviewController; |
| | 37 | | } |
| | 38 | |
|
| 425 | 39 | | void IDisposable.Dispose() { } |
| | 40 | |
|
| | 41 | | void IService.Initialize() => |
| 425 | 42 | | prefab = Resources.Load<CharacterPreviewController>("CharacterPreview"); |
| | 43 | | } |
| | 44 | | } |