Home>

I get an error that the SerializeField reference doesn't work.
Please teach me.

Applicable source code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player: MonoBehaviour {
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager: MonoBehaviour {
    [SerializeField]
    Player player;
    void Start () {
        Player player = Instantiate (player);// A red line appears on the player on the right side.
    }
    void Update () {
    }
}


Error message.

Assets/GameManager.cs (12,31): error CS0165: Use of unassigned local variable `player '
Resolution code.
Player myPlayer = Instantiate (player);