Untitled

 avatar
unknown
plain_text
3 years ago
723 B
5
No Index
// Assuming use case for instantiated objects:
SomeComponent someComponent = GameObject.Instantiate(prefab) as SomeComponent;
someComponent.Init(player);

....

public class SomeComponent : MonoBehaviour {

    // [SerializeField] GameObject player; // <- Version A - I can see if the player was initialized properly
    GameObject player; // <- Version B - nothing is visible in the inspector
    private void Start()
    {
        // I cannot tell if player is assigned at this point without debugging or using [SerializeField] (Version A)
        // But then it looks like unassigned property in the Editor and makes me confused.
    }

    public void Init(GameObject player)
    {
        this.player = player;
    }
}
Editor is loading...