반응형
화면 전체 재생
RAW Image에 재생
1. Video Player를 하나 만듦
2. RawImage를 하나 만듦
3. Raw Image의 Texture를 VideoPlayer걸로 바꿈
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class VideoHandler : MonoBehaviour
{
public RawImage mScreen;
public VideoPlayer mVideoPlayer;
void Start()
{
if (mScreen != null && mVideoPlayer != null)
{
StartCoroutine(PrepareVideo());
}
}
protected IEnumerator PrepareVideo()
{
// 비디오 준비
mVideoPlayer.Prepare();
// 비디오가 준비되는 것을 기다림
while (!mVideoPlayer.isPrepared)
{
yield return new WaitForSeconds(0.5f);
}
// VideoPlayer의 출력 texture를 RawImage의 texture로 설정한다
mScreen.texture = mVideoPlayer.texture;
}
public void PlayVideo()
{
if (mVideoPlayer != null && mVideoPlayer.isPrepared)
{
// 비디오 재생
mVideoPlayer.Play();
}
}
public void StopVideo()
{
if (mVideoPlayer != null && mVideoPlayer.isPrepared)
{
// 비디오 멈춤
mVideoPlayer.Stop();
}
}
}
UI의 RawImage에 재생
[Unity] 유니티 2D UI Canvas 타겟으로 VideoPlayer 사용
오디오와 마찬가지로 유니티에서 비디오를 재생하는 간단한 방법이 추가되었다. VideoPlayer가 그것인데 이것을 이용해 여러 비디오 파일을 플랫폼 독립적으로 재생할 수 있다. VideoPlayer를 사용하
calvinjmkim.tistory.com
전체화면 재생
유니티에서 영상 재생을 하자 Media player
이 단락에서 설명드릴 부분은 유니티 5.6 이상의 버전에서만 적용됩니다. 하위 버전은 적용되지 않으니 주의하세요 또한 만일, 이 방법을 적용하고자 버전을 올리신다면 버전을 올리기 전 반드
computer-warehouse.tistory.com
반응형
'Unity > Unity 리서치' 카테고리의 다른 글
Canvas와 World좌표 연동 (Camera.WorldToScreenPoint) (0) | 2021.07.16 |
---|---|
RectTransform의 width, height 알아내기 (0) | 2021.07.13 |
Loading Scnene 구현 (0) | 2021.07.12 |
Unity Language Localization (0) | 2021.07.11 |
TextmeshPro 한글폰트 적용 (0) | 2021.07.11 |