Skip to content

Commit

Permalink
fix(sample): the default video/image is not selected (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
homuler committed Apr 27, 2022
1 parent 6b8c674 commit 77ba1a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ public class StaticImageSource : ImageSource
private Texture _image;
private Texture image
{
get => _image;
get
{
if (_image == null && _availableSources != null && _availableSources.Length > 0)
{
image = _availableSources[0];
}
return _image;
}
set
{
_image = value;
Expand All @@ -47,14 +54,6 @@ private Texture image
private bool _isPlaying = false;
public override bool isPlaying => _isPlaying;

private void Start()
{
if (_availableSources != null && _availableSources.Length > 0)
{
image = _availableSources[0];
}
}

public override void SelectSource(int sourceId)
{
if (sourceId < 0 || sourceId >= _availableSources.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ public class VideoSource : ImageSource
private VideoClip _video;
private VideoClip video
{
get => _video;
get
{
if (_video == null && _availableSources != null && _availableSources.Length > 0)
{
video = _availableSources[0];
}
return _video;
}
set
{
_video = value;
Expand All @@ -38,14 +45,6 @@ private VideoClip video
public override bool isPlaying => _videoPlayer != null && _videoPlayer.isPlaying;
public override bool isPrepared => _videoPlayer != null && _videoPlayer.isPrepared;

private void Start()
{
if (_availableSources != null && _availableSources.Length > 0)
{
video = _availableSources[0];
}
}

public override void SelectSource(int sourceId)
{
if (sourceId < 0 || sourceId >= _availableSources.Length)
Expand Down

0 comments on commit 77ba1a4

Please sign in to comment.