IEnumerator CallDB() { foreach (Transform child in listable.transform) { GameObject.Destroy(child.gameObject); } GameObject header = Instantiate(headtext); header.transform.parent = listable.transform; header.transform.localScale = Vector3.one; header.SetActive(false); notetext.color = Color.white; notetext.text = "Connecting to database..."; WWW www = new WWW(path); yield return(www); notetext.color = Color.white; notetext.text = "Searching database..."; if (www.error != null)//error is found { notetext.color = Color.red; notetext.text = www.text; } /*if (gameObject.tag != "refbut") * { * refbutscript.drinkselect = gameObject.name; * }*/ //Here's where the magic happens var radius = 50f; if (distinput.text != "") { radius = float.Parse(distinput.text); } var matchfound = false; string[] temp = www.text.Split("^".ToCharArray()); Debug.Log("Temp is " + temp.Length); for (var i = 0; i < temp.Length - 1; i += 1) { string[] othert = temp[i].Split("*".ToCharArray()); var dist = measure(float.Parse(othert[1]), float.Parse(othert[2]), herex, herey); if (dist <= radius) { header.SetActive(true); //now create a thing if the distance checks out matchfound = true; GameObject newdig = Instantiate(locationobject); newdig.transform.parent = listable.transform; var digscript = newdig.GetComponent <ShindigScript>(); digscript.popuppanel = popuppanel; digscript.Lname = othert[0]; digscript.Distance = measure(float.Parse(othert[1]), float.Parse(othert[2]), herex, herey); digscript.Address = othert[4]; digscript.Website = othert[5]; digscript.Ldesc = othert[3]; digscript.Lid = othert[6]; } yield return(null); } notetext.color = Color.white; notetext.text = "List completed!"; StartCoroutine(fader.GetToFadin()); GameObject lastpart = Instantiate(bottombut); lastpart.transform.parent = listable.transform; lastpart.transform.localScale = Vector3.one; submitvenuewindow.SetActive(true); var butscript = lastpart.GetComponent <ActiveSetButtonScript>().target = submitvenuewindow; submitvenuewindow.SetActive(false); if (matchfound == false) { notetext.color = Color.red; notetext.text = "No results found."; } backbut.interactable = true; isrunning = false; }
IEnumerator CallDB() { foreach (Transform child in listable.transform) { GameObject.Destroy(child.gameObject); } notetext.color = Color.white; notetext.text = "Connecting to database..."; WWW www = new WWW(path); yield return(www); notetext.color = Color.white; notetext.text = "Searching database..."; if (www.error != null)//error is found { notetext.color = Color.red; notetext.text = www.text; } /*if (gameObject.tag != "refbut") * { * refbutscript.drinkselect = gameObject.name; * }*/ //Here's where the magic happens var radius = 50f; if (distinput.text != "") { radius = float.Parse(distinput.text); } var utcdif = System.DateTime.UtcNow - System.DateTime.Now; var matchfound = false; string[] temp = www.text.Split("^".ToCharArray()); Debug.Log("Temp is " + temp.Length); for (var i = 0; i < temp.Length - 1; i += 1) { string[] othert = temp[i].Split("*".ToCharArray()); var checklistmatch = false; foreach (Transform child in listselect.transform) //check all checkboxes { if (child.gameObject.name == othert[10]) //current checkbox matches event category { var boxscript = child.gameObject.GetComponent <Toggle>(); if (boxscript.isOn == true) //current checkbox is selected { checklistmatch = true; } break; } } var dist = measure(float.Parse(othert[5]), float.Parse(othert[6]), herex, herey); if (dist <= radius && checklistmatch == true) { //now create a thing if the distance checks out matchfound = true; GameObject newdig = Instantiate(shindigobject); newdig.transform.parent = listable.transform; var digscript = newdig.GetComponent <ShindigScript>(); digscript.popuppanel = popuppanel; digscript.utcdifference = utcdif; digscript.Lname = othert[4]; digscript.Sname = othert[0]; digscript.Begin = othert[1]; digscript.Distance = measure(float.Parse(othert[5]), float.Parse(othert[6]), herex, herey); digscript.Address = othert[8]; digscript.Website = othert[9]; digscript.Ldesc = othert[7]; digscript.Sdesc = othert[3]; digscript.Lid = othert[12]; } yield return(null); } notetext.color = Color.white; notetext.text = "List completed!"; StartCoroutine(fader.GetToFadin()); GameObject lastpart = Instantiate(bottombut); lastpart.transform.parent = listable.transform; lastpart.transform.localScale = Vector3.one; if (matchfound == false) { notetext.color = Color.red; notetext.text = "No results found."; if (firstattempt == true) { notetext.color = Color.white; notetext.text = "Give it a minute."; firstattempt = false; StartCoroutine(LocationMethod()); } } backbut.interactable = true; isrunning = false; }