c# 강의/유니티
20200511 - Scene
쪼혀
2020. 5. 11. 10:44
> 정리
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Newtonsoft.Json;
public class App : MonoBehaviour
{
float timer;
int logoWaitingTime;
int titleWaitingTime;
private void Awake()
{
UnityEngine.Object.DontDestroyOnLoad(this);
}
void Start()
{
this.timer = 0.0f; // 타이머
this.logoWaitingTime = 1; // 로고 시간
this.titleWaitingTime = 1; // 타이틀 시간
}
// Update is called once per frame
void Update()
{
this.timer += Time.deltaTime;
if (this.timer > logoWaitingTime){
SceneManager.LoadScene("Logo");
}
if (this.timer > titleWaitingTime){
SceneManager.LoadScene("Title");
this.timer = 0.0f;
}
}
}
> 씬 적용 순서
강의중 기록
App - 로고 - 타이틀 - 로딩화면 - 로비 - 인게임
App: 진입씬
여러가지 씬들은 전환될수 있다
- 씬 (로고, 타이틀)
- 팝업: 닫기 버튼이 무조건 있음
- 페이지: 뒤로가기가 무조건 있음
// 팝업과 페이지는 씬으로 보지 않음
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class App : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// logo 씬으로 전환
SceneManager.LoadScene("logo");
}
// Update is called once per frame
void Update()
{
}
void log(object data)
{
Debug.Log(data);
}
}
> app -> logo -> title
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class App : MonoBehaviour
{
// Start is called before the first frame update
private void Awake()
{
UnityEngine.Object.DontDestroyOnLoad(this);
}
void Start()
{
// logo 씬으로 전환
SceneManager.LoadScene("logo");
}
// Update is called once per frame
void Update()
{
}
void log(object data)
{
Debug.Log(data);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Title : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
this.log("down click");
SceneManager.LoadScene("Lobby");
}
if (Input.GetMouseButtonUp(0))
{
this.log("up click");
SceneManager.LoadScene("Lobby");
}
}
void log(object data)
{
Debug.Log(data);
}
}