백지부터 시작하는 이세계 코딩 생활
Warning cs0649 해결방법 본문
warning CS0649: Field is never assigned to, and will always have its default value 'null'
나의 해결 방법 >> 디버깅 한번 해주고 나니 깔금하게 해결 되었다.
상황 >> private Rigidbody2D rigid2D; 선언했을 때 해당 컴포넌트의 null 에러가 발생했었다.
그 밖에 >> 스크립트 파일과 오브젝트를 연결되지 않았는지 확인해 볼 것.
보통 코딩 하고 솔루션 빌드(Ctrl + Shift + B)로 에러사항 확인했었는데 이때, 발생한 에러였다.
디버깅 해주고 나니 같은 방법으로 솔루션 빌드를 해도 CS0649 경고메세지가 나타나지 않았다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RabbitController : MonoBehaviour
{
private Rigidbody2D rigid2D;
private float jumpForce = 250.0f;
// Start is called before the first frame update
void Start()
{
rigid2D = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rigid2D.AddForce(transform.up * jumpForce);
}
}
}
! 동일한 작업 중에 발생한 경고문이 아닐 수 있으므로 참고만 할 것 !
검색해 보면, 보통은 경고 메세지를 죽이는 방법을 제시한다.
Ref : wakeupjava.tistory.com/222
cf. 2018년도 당시 사용하던 버전에서는 버그라고 일컫어 졌지만 지금 (2020년도) 버전에선 해결된 듯 싶다.
Comments