Unity on Android and pointers

I made an application and I’m currently trying to get it to work on Android. Obviously the application runs without any problems on Windows. However, I can’t get it to run properly on Android.

Somehow pointers (not sure if this is the correct description) are always null. For example, the following piece of code works flawlessly:

if (LevelManager.Instance.levelSettings.newGame != null)
     testtest = "container not null";
else
     testtest = "container null";

In mycase this will always say “container not null”. But when I try the following code it fails:

this.newGame = LevelManager.Instance.levelSettings.newGame;

if (this.newGame != null)
     testtest = "container not null";
else
     testtest = "container null";

This will always generate the “container null” output. This is quite frustrating, it would mean I need to replace all code containing such pointers which is very time consuming and less neat. Code written in this manner is also a tad bit slower.

Anyway hoping to get some insights into this problem :p.

I’m not sure I understand what the code you posted is trying to do. What does the code look like for LevelManager.Instance.levelSettings.newGame? Is it a property?

This is not exactly the code I’m using, I only try to show in what instance it fails.

public TextureContainer newGame { get; private set; } // The new game button texture

newGame is indeed a property with as type TextureContainer, a custom class I made. This is not a class derived from monobehaviour therefore it is not attached to any gameobject directly.

p.s. I hope you saw the post after me editing it because it contained a stupid copy/paste error.

Ah, I missed your updated post - the current one makes more sense :wink: Although I’m still not really sure why this would fail only for Android. That doesn’t make any sense. I’m guessing there must be something else causing the values to be null. If you create a small repro project and file a bugreport I can take a look and see if I can figure out what is going on.

I’ll try to reproduce the problem in a new project.

Ok found the problem, it is my fault :p. I thought I deactivated all code that used:

DirectoryInfo info = new DirectoryInfo(unityPath + subDir + "/");
FileInfo[] files = info.GetFiles();

Seems I missed some. Then for my next question, is there a way to reproduce the effects of that code with Resources.Load?
My goal is to get a list of files located in that directory.

Another way to solve this is loading that data from an xml file for example. However, I prefer another solution.