📝 23.12.12
기존의 팀원이 구현한 방법은 각 영상(7개)에 대해 각각의 씬을 생성한 것이었다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.IO;
public class IntroChange : MonoBehaviour
{
string path;
public void Start()
{
path = Path.Combine(Application.dataPath, "database.json");
if (!File.Exists(path))
{
GameObject skip = GameObject.Find("Canvas/Button");
if(skip != null)
skip.SetActive(false);
}
}
public void SceneChange()
{
if(SceneManager.GetActiveScene().name == "IntroScene1")
{
SceneManager.LoadScene("IntroScene2");
} else if(SceneManager.GetActiveScene().name == "IntroScene2")
{
SceneManager.LoadScene("IntroScene3");
} else if(SceneManager.GetActiveScene().name == "IntroScene3")
{
SceneManager.LoadScene("IntroScene4");
} else if(SceneManager.GetActiveScene().name == "IntroScene4")
{
SceneManager.LoadScene("IntroScene5");
} else if(SceneManager.GetActiveScene().name == "IntroScene5")
{
SceneManager.LoadScene("IntroScene6");
} else if(SceneManager.GetActiveScene().name == "IntroScene6")
{
SceneManager.LoadScene("IntroScene7");
} else if(SceneManager.GetActiveScene().name == "IntroScene7")
{
SceneManager.LoadScene("StartScene");
}
}
public void SkipScene()
{
SceneManager.LoadScene("StartScene");
}
}
당연히 씬 사용에 있어서 비효율적이기 때문에 씬을 하나로 통합하고 동일한 기능을 제공하는 방법을 구상했다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.IO;
public class IntroChange : MonoBehaviour
{
public VideoPlayer myVideo;
public VideoClip[] clips;
public GameObject nextBtn;
string path;
int sceneNum = 0;
public float playTime = 0f;
public void Start()
{
playTime = (float) myVideo.length;
sceneNum = 0;
path = Path.Combine(Application.dataPath, "database.json");
if (!File.Exists(path))
{
GameObject skip = GameObject.Find("Canvas/Button");
if(skip != null)
skip.SetActive(false);
}
}
void Update()
{
playTime -= Time.deltaTime;
if (playTime < 0.1f)
{
playTime = 0.0f;
nextBtn.SetActive(true);
}
}
public void VideoChange()
{
sceneNum++;
if (sceneNum < 7)
{
nextBtn.SetActive(false);
myVideo.clip = clips[sceneNum];
myVideo.time = 0f;
playTime = (float) myVideo.length;
myVideo.Play();
} else
{
SkipScene();
}
}
public void SkipScene()
{
SceneManager.LoadScene("StartScene");
}
}
스크립트 교체 과정에서 기존의 버튼 fade 이펙트를 아직 적용하지 못했다. 매번 씬 로드를 했던 것을 이용하여 Start()로 구현했던 이펙트라서 수정 과정에서 어떤 시점에 넣어야 할 지 구상을 좀 해봐야 할 것 같다.