Skip to content

Commit

Permalink
feat: requested change
Browse files Browse the repository at this point in the history
  • Loading branch information
rYuuk committed Nov 29, 2023
1 parent 0fb4ae4 commit 4c06e5c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Runtime/AvatarCreator/UI/PhotoCaptureElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ public class PhotoCaptureElement : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private RawImage cameraTextureTarget;
[SerializeField] private bool initializeOnAwake = true;

[Space(5)]
[Header("Events")]
public UnityEvent<Texture2D> onPhotoCaptured;

private WebCamTexture cameraTexture;
private bool isInitialized;

private void Awake()
{
InitializeCamera();
if (initializeOnAwake)
{
StartCamera();
}
}

public void StartCamera()
{
if (!isInitialized)
{
InitializeCamera();
}

if (cameraTexture != null && !cameraTexture.isPlaying)
{
cameraTexture.Play();
Expand Down Expand Up @@ -52,9 +62,8 @@ public void TakePhoto()
private void InitializeCamera()
{
var webCamDevice = GetWebCamDevice();

SetupPhotoBoothTexture(webCamDevice?.name);
StartCamera();
isInitialized = true;
}

private void SetupPhotoBoothTexture(string textureName)
Expand Down

0 comments on commit 4c06e5c

Please sign in to comment.