fix: now handles errors better without killing the entire process
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Reset.Core.Tools{
|
||||
GameObject thisPageObject = null;
|
||||
bool alreadyExisted = false;
|
||||
|
||||
// This checks for a gameobject with the page name. Sets it if it finds it
|
||||
// This checks for a page with the gameobject's name. Sets it if it finds it
|
||||
foreach (var page in Instance.Pages) {
|
||||
if (page.Key.name == $"{Instance.pageNamePrefix}{pageName}") {
|
||||
thisPageObject = page.Key;
|
||||
@@ -82,7 +82,7 @@ namespace Reset.Core.Tools{
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, this will make a new one and add it
|
||||
// Otherwise, this will make a new GameObject/page and add it
|
||||
UIDocument thisDocument;
|
||||
|
||||
if (thisPageObject == null) {
|
||||
@@ -92,7 +92,7 @@ namespace Reset.Core.Tools{
|
||||
// Add it to the list of page objects and set it's transform
|
||||
KeyValuePair<GameObject, List<string>> newPage = new(thisPageObject, new List<string>());
|
||||
Instance.Pages.Add(newPage.Key, newPage.Value);
|
||||
thisPageObject.transform.SetParent(Instance.canvasRootGameObject.transform);
|
||||
thisPageObject.transform.SetParent(Instance.root.transform);
|
||||
|
||||
// Add a UI Document for it, give it the base template
|
||||
thisDocument = thisPageObject.AddComponent<UIDocument>();
|
||||
@@ -140,16 +140,14 @@ namespace Reset.Core.Tools{
|
||||
// Publicly accessible method to change the value
|
||||
public static void ChangeValue(string pageName, string sourceName, string newValue){
|
||||
try {
|
||||
Instance.values[$"{pageName}/{sourceName}"].text = newValue;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
if (Instance.values.ContainsKey($"{pageName}/{sourceName}")) {
|
||||
Instance.values[$"{pageName}/{sourceName}"].text = newValue.ToString();
|
||||
} else {
|
||||
AddOnOverlay(pageName, sourceName);
|
||||
Instance.values[$"{pageName}/{sourceName}"].text = newValue;
|
||||
throw;
|
||||
} catch (Exception exception) {
|
||||
Debug.LogError($"Failed to both update an existing or create a new debug overlay: {exception.Message}" );
|
||||
throw;
|
||||
Instance.values[$"{pageName}/{sourceName}"].text = newValue.ToString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed to both update an existing or create a new debug overlay: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user