LoginSignup
2
1

More than 5 years have passed since last update.

【Unity】Warning CS0649が出る場合の対応(is never assigned to, and will always have its default value 0)

Posted at

環境メモ
⭐️Mac OS Mojave バージョン10.14
⭐️Unity 2018.2.15f1

以下のエラーになる場合

DestroyScript.cs(28,28):
Warning CS0649: Field 'DestroyScript.life' is never assigned to, and will always have its default value 0 (CS0649) (Assembly-CSharp)

#pragma warning disable 0649

を追加すればOK

DestroyScript
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/*
 * Prefabsの「bullet」と「HitParticles」
 */
public class DestroyScript : MonoBehaviour {
#pragma warning disable 0649
    [SerializeField] float life;
    void Start () {
        // 球のゲームオブジェクトを破棄する
        Destroy(gameObject, life);
    }
}

2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1