Search Unity

Resources Questions

Discussion in 'Asset Bundles' started by cyclops1970, Sep 9, 2018.

  1. cyclops1970

    cyclops1970

    Joined:
    Mar 6, 2018
    Posts:
    11
    Sorry if this is the wrong spot....

    G'day everyone,

    I have something setup which loads from the resources folder(line 35 in LevelGenerator)
    currentLevel = Resources.Load<Texture2D>(GameManager.manager.currentLevel.ToString());

    This works fine within unity, but when I build to PC (it is a mobile game, but that isn't building properly either, so I tried PC) I am getting the following error:

    NullReferenceException: A null value was found where an object instance was required.
    at LevelGenerator.GenerateLevel () [0x00001] in C:\My Games\BlockBash\Assets\Scripts\LevelGenerator.cs:35
    at PlayLevel.Start () [0x0003a] in C:\My Games\BlockBash\Assets\Scripts\PlayLevel.cs:73

    (Filename: C:/My Games/BlockBash/Assets/Scripts/LevelGenerator.cs Line: 35)

    In my build resources folder I have two files....is this correct??
    unity_default_resources
    unity_builtin_extra

    Any information appreciated!
     
  2. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    That doesn't seem to be a problem with resources. Since something is causing a NullReferenceException on that line, the problem is either GameManager, .manager or .currentLevel. Add logging to see which one of these is null.

    EDIT: Though of course if GameManager.manager is a static property, then you can skip checking whether GameManager is null and focus on the values returned by .manager and .currentLevel.
     
  3. cyclops1970

    cyclops1970

    Joined:
    Mar 6, 2018
    Posts:
    11
    OK, will look into it, thanks :)

    Disregarding that though, are the files in the resources folder in a build, all compressed together? And if so, what is the name of that file?

    Thanks.