저는 C#의 주간/야간 순환 스크립트를 사용하여 주변을 둘러보고 있습니다. 그것이 좋은 것인지 전혀 모른다. C#을 처음 접했을 때부터 C#에서 사물을 시도하고있다. 여기 꽤 괜찮은 코드가 있다고 생각합니다. 디버그는 게임을 테스트하기 전에는 아무 말도하지 않습니다. 나는 그것을 테스트 할 때, 그것은 말할 것이다 :소스 유형을 대상 유형 반복 변환으로 변환 할 수 없습니다.
using UnityEngine;
using System.Collections;
public class cycleFlow : MonoBehaviour {
private Color night;
private Color day;
void Start() {
night [0] = 30;
night [1] = 30;
night [2] = 30;
day [0] = 255;
day [1] = 255;
day [2] = 255;
}
void Update() {
DayNightCycle();
}
void DayNightCycle()
{
foreach (SpriteRenderer child in transform)
if(Input.GetKeyDown(KeyCode.Q))
child.color = Color.Lerp(child.color, night, Time.deltaTime);
foreach (SpriteRenderer child in transform)
if(Input.GetKeyDown(KeyCode.E))
child.color = Color.Lerp(child.color, day, Time.deltaTime);
}
}
을 무슨 일이야 :
InvalidCastException: Cannot cast from source type to destination type. cycleFlow.DayNightCycle() (at Assets/Scripts/cycleFlow.cs:28) cycleFlow.Update() (at Assets/Scripts/cycleFlow.cs:14)
이 내가 가지고 무엇인가? (처음 BTW 여기 게시, 나는 아무것도 잘못하지 미안 경우)