Hi all.
I recently updated my project to unity 2017.1.0p5 and meat strange behaviour.
When i load local file using WWW class and then try to check responseHeaders property of WWW class instance. It throws exception:
ERROR:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.WWW.get_responseHeaders () (at C:/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:158)
TestLocalLoading+<LoadLocalFile>c__Iterator0.MoveNext () (at Assets/Scripts/TestLocalLoading.cs:20)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
SAMPLE CODE:
public class TestLocalLoading : MonoBehaviour
{
public void TesLoacalLoading()
{
StartCoroutine(LoadLocalFile());
}
private static IEnumerator LoadLocalFile()
{
var filePath = "file://" + Application.dataPath + "/TestLocalLoading.txt";
var www = new WWW(filePath);
while (!www.isDone)
yield return www;
Debug.LogFormat("www.text: {0}", www.text); // file loaded correctly
Debug.LogFormat("www.responseHeaders: {0}", www.responseHeaders); // this line produce exception
}
}
It’s just a simple code to reproduce error.
In Unity 5.3.4p1 all was fine. But since WWW became a wrapper for UnityWebRequest I start getting errors.