Question by
altropetrolio · Dec 24, 2020 at 12:47 PM ·
errorlistvariablewebrequestdisappearing
List suddenly auto-clear after WebRequest (in another Script)?
Hi at all. Strange issue happen. I've implemented a small call WebRequest to Api DropBox (check here the final solution i've found)
Now I'm in trouble with a strange issue : I've declared a List . But after returning from WebRequest (it is in another Script) suddenly List.Count become = 0. I've checked carefully all calls, but in noways this "List" is touched... but it will lost after WebRequest. Not sure but I'm believe that I should find a "way" to keep it in memory (but don't know how).
private void Loader()
{
// Copy a Photo List from Shared Variables
for (int i = 0; i< VideoGames_SharedVar.PhotoList.Count; i++)
{
PhotoListDropBox.Add(VideoGames_SharedVar.PhotoList[i]);
}
// Path per DropBox
DropBoxImagePath = "";
DropBoxLoadDone=false;
}
private IEnumerator ImageParse()
{
DropBoxFullLoad=false;
// Go Thru all Images
for (int i = 0; i < PhotoListDropBox.Count; i++)
{
// Processing Url for WebRequest
string[] StringArray = PhotoListDropBox[i].Split(new string[] {"\\"}, StringSplitOptions.None);
DropBoxImagePath = StringArray[StringArray.Length-1];
DropBoxImagePath = "/Shared Folder/" + DropBoxImagePath;
// Call WebRequest on another script
WebRequestScript.PressMe();
// Wait until loading from Webrequest is done (list count is OK)
while (DropBoxLoadDone==false)
{
yield return null;
};
// HERE MY LIST BECAME ZERO
string TempString = CercaSharedURL();
PhotoListDropBox[i] = TempString;
// Above error is generated because PhotoListDropBox is null
}
DropBoxFullLoad=true;
Comment
Answer by altropetrolio · Dec 25, 2020 at 08:54 AM
Maybe I've figured out the Issue. Same list was "copied" but in someway when applied a ListName.Clear() it delete both list. Now I will avoid ListName.Clear() and use always ListName = new List()