From 3cbc823b885a70c89c8561cea9ed6f17eded6fe0 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 25 Feb 2022 07:26:02 -0800 Subject: [PATCH 1/5] Added path dump for debug raycaster --- NewHorizons/Utility/DebugRaycaster.cs | 7 ++++--- NewHorizons/Utility/SearchUtilities.cs | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Utility/DebugRaycaster.cs b/NewHorizons/Utility/DebugRaycaster.cs index fa7d4760..2394a914 100644 --- a/NewHorizons/Utility/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugRaycaster.cs @@ -1,4 +1,5 @@ -using NewHorizons.Builder.Body; +using NewHorizons; +using NewHorizons.Builder.Body; using System; using System.Collections.Generic; using System.Linq; @@ -21,7 +22,7 @@ namespace NewHorizons.Utility private void Update() { - if (Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame) + if (Main.Debug && Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame) { // Raycast _rb.DisableCollisionDetection(); @@ -31,7 +32,7 @@ namespace NewHorizons.Utility if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask)) { var pos = hitInfo.transform.InverseTransformPoint(hitInfo.point); - Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{hitInfo.transform.gameObject.name}]"); + Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{hitInfo.transform.gameObject.name}] at [{GetPath(hitInfo.transform.gameObject)}]"); } _rb.EnableCollisionDetection(); } diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index bd164b7b..90a50b02 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -172,5 +172,16 @@ namespace NewHorizons.Utility } return children; } + + public static string GetPath(GameObject obj) + { + string path = "/" + obj.name; + while (obj.transform.parent != null) + { + obj = obj.transform.parent.gameObject; + path = "/" + obj.name + path; + } + return path; + } } } From a111c9aec57af9b9570e86022cffd2d297b9c394 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 25 Feb 2022 16:20:20 -0500 Subject: [PATCH 2/5] Fixed Reference Error --- NewHorizons/Utility/DebugRaycaster.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Utility/DebugRaycaster.cs b/NewHorizons/Utility/DebugRaycaster.cs index 2394a914..4cfde913 100644 --- a/NewHorizons/Utility/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugRaycaster.cs @@ -32,7 +32,8 @@ namespace NewHorizons.Utility if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask)) { var pos = hitInfo.transform.InverseTransformPoint(hitInfo.point); - Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{hitInfo.transform.gameObject.name}] at [{GetPath(hitInfo.transform.gameObject)}]"); + var o = hitInfo.transform.gameObject; + Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{o.name}] at [{SearchUtilities.GetPath(o)}]"); } _rb.EnableCollisionDetection(); } From 60442e57250b56275730febcc5bf75a205c93dca Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 25 Feb 2022 18:14:10 -0500 Subject: [PATCH 3/5] Fixed Asset Bundles Not Reloading --- NewHorizons/Main.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 04a6abdd..547cb0bc 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -140,6 +140,7 @@ namespace NewHorizons { BodyDict["SolarSystem"] = new List(); SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this); + AssetBundles.Clear(); Logger.Log("Begin reload of config files...", Logger.LogType.Log); From a22ef0f1246d147959445bc6f1b47fc978df798b Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 25 Feb 2022 19:25:05 -0500 Subject: [PATCH 4/5] Unload asset bundles on reload --- NewHorizons/Main.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 547cb0bc..7566a39a 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -140,6 +140,10 @@ namespace NewHorizons { BodyDict["SolarSystem"] = new List(); SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this); + foreach (AssetBundle bundle in AssetBundles.Values) + { + bundle.Unload(true); + } AssetBundles.Clear(); Logger.Log("Begin reload of config files...", Logger.LogType.Log); From 7df1c1e476316d83fb869945409460df8b63ec65 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 25 Feb 2022 20:15:36 -0500 Subject: [PATCH 5/5] I'm blind --- NewHorizons/Utility/DebugRaycaster.cs | 2 +- NewHorizons/Utility/SearchUtilities.cs | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/NewHorizons/Utility/DebugRaycaster.cs b/NewHorizons/Utility/DebugRaycaster.cs index 4cfde913..ce398b65 100644 --- a/NewHorizons/Utility/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugRaycaster.cs @@ -33,7 +33,7 @@ namespace NewHorizons.Utility { var pos = hitInfo.transform.InverseTransformPoint(hitInfo.point); var o = hitInfo.transform.gameObject; - Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{o.name}] at [{SearchUtilities.GetPath(o)}]"); + Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{o.name}] at [{SearchUtilities.GetPath(o.transform)}]"); } _rb.EnableCollisionDetection(); } diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 90a50b02..bd164b7b 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -172,16 +172,5 @@ namespace NewHorizons.Utility } return children; } - - public static string GetPath(GameObject obj) - { - string path = "/" + obj.name; - while (obj.transform.parent != null) - { - obj = obj.transform.parent.gameObject; - path = "/" + obj.name + path; - } - return path; - } } }