2020-05-11 [unity]
오늘 이리저리 메모 >
GameObJect.FindWithTag
APP - 로고 - 타이틀 - 로딩화면 - 로비 - 인게임
(진입씬)
씬 (화면 전체가 바뀜 / 완전히 다른 화면으로 보이는게 대부분임)
팝업
ㄴ (화면에 띄워지는것, 닫기버튼 있음)
페이지
ㄴ (뒤로가기가 있는 것)
씬전환
SceneManager.LoadScene("string");
버튼클릭처리하기
Input.GetMouseButtonDown(0)
Input.GetMouseButtonUp(0)
씬전환
APP - LOGO - TITLE - LOBBY
역직렬화
TextAsset textAsset = Resources.Load("Data/character_data") as TextAsset;
string json = textAsset.text;
모노를 상속 받지 못했다면 컴포넌트로 활용하지 못한다.
상속 받았다면 컴포넌트로 활용하고 인스턴스화 할때 new 사용 X
SceneManager.sceneLoaded += SceneManager_sceneLoaded; // 씬이 로드 되었다면 오른쪽 메소드 호출
상기 문법은 하나의 대기 진동벨을 받았다고 비유 생각하면 편함
동작 시행을 명령 후, 동작 됬을 시 해당 문법 실행
순차적 진행 X
>> UnityAction
대리자는 형식이다.
대리자, 메소드를 집어넣을 수 있다.
메소드를 호출하듯이 씀. 대신씀.
변수마냥 사용되었고
마치 변수 안에 메소드를 넣은거처럼 사용 됨.
선언하고, 연결하고. ~~~.변수 += () => {};
정의. 호출.
delegate 선언
public Unityaction onDieComplete;
delegate ㅇ녀결
this.hero.onMoveComplete += this.HeroMoveComplete;
private void Hero Diecomple() {
Debuug.Log("히로 다이컴플리ㅌ,");
}
delegate 호출
this.onDieCompletate;
씬 전환
SceneManager.LoadScene("InGame");
대리자 (UnitiyAction)
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
json 로드
TextAsset textAsset = Resources.Load("Data/character_data"_ as TextAsset;
오늘 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Events;
void Start()
{
button.onClick.AddListener(() =>
{
SceneManager.sceneLoaded += SceneManager_sceneLoaded; // 씬이 로드 되었다면 오른쪽 메소드 호출
SceneManager.LoadScene("InGame");
});
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
//var inGame = GameObject.FindObjectOfType<InGame>();
//inGame.Init(this.CharacterId);
//Debug.LogFormat("InGame : {0}", inGame); // 이건 타입으로 해당 인스턴스를 가져옴
var inGamego = GameObject.Find("InGame"); // 이건 게임오브젝트를 가져온것
var inGame = inGamego.GetComponent<InGame>();
inGame.Init(this.characterId);
Debug.Log(inGame);
}
|
cs |