Search Unity

Why can't Application.streamingAssetsPath and friends be called from MonoBehaviour constructors?

Discussion in 'Scripting' started by Ramobo, Sep 15, 2019.

  1. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    By now the fact should be common knowledge, but not the why.

    Primarily what I'm interested in are "Application.persistentDataPath" and "Screen.resolutions". I can see ways to implement them without touching the Unity API, so in my vision, it would be just a helper.
     
  2. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    What do you mean by monobehaviour constructors?
     
  3. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    Constructors of MonoBehaviours. Also applies to their field initializers.