I have a working Scroll view that builds content perfectly fine via data driven. problem is when I try to load a new text document, it holds on to the previous document and adds the new text. I need to empty the text and only add the new text:
IEnumerator SetupHelpDocumentText(string uri, object obj)
{
try
{
GameObject newObj = new GameObject();
string json = JsonConvert.SerializeObject(obj);
var client = new HttpClient();
var webRequest = WebRequest.Create(uri);
webRequest.Method = "POST";
webRequest.ContentType = "application/json";
using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
{
streamWriter.Write(json);
}
var httpResponse = (HttpWebResponse)webRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
_Help_Document = JsonConvert.DeserializeObject<string>(result);
}
newObj = Instantiate(_txttxtHelpDocument, transform);
newObj.GetComponent<Text>().text = _Help_Document;
}
catch (Exception ex)
{
Debug.Log(ex);
Debug.Log("Failed To Load Help Document");
}
yield return null;
}