
안녕하세요~ 언제나 수고 많으십니다!
이번 4-6. [카드에 르탄이 넣기] 강의 후반부를 학습하던 중, 강의대로 따라해보았지만 'rtan7' 이미지만 아래 캡처와 같이 등장하지 않네요.
혹시나 싶어 재부팅을 하거나 Resources 폴더에 모든 파일 재등록 또한 시도해보았지만 마찬가지로 해당 파일만 화면에 출력되지 않았습니다.
무엇이 문제인걸까요?
.png)
작성한 코드 및 에러 메세지
// gameManager 코드입니다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
public class gameManager : MonoBehaviour
{
public Text timeTxt;
public GameObject card;
float time = 0.0f;
// Start is called before the first frame update
void Start()
{
int[] rtans = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
rtans = rtans.OrderBy(item => Random.Range(-1.0f, 1.0f)).ToArray();
for (int i = 0; i < 16; i++)
{
GameObject newCard = Instantiate(card);
newCard.transform.parent = GameObject.Find("cards").transform;
float x = (i / 4) * 1.4f - 2.1f;
float y = (i % 4) * 1.4f - 3.0f;
newCard.transform.position = new Vector3(x, y, 0);
string rtanName = "rtan" + rtans[i].ToString();
newCard.transform.Find("front").GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>(rtanName);
}
}
// Update is called once per frame
void Update()
{
time += Time.deltaTime;
timeTxt.text = time.ToString("N2");
}
}
