Check if reticle image exists before instantiating

This commit is contained in:
Noah Pilarski 2022-09-03 16:16:24 -04:00
parent 25bdb7dd82
commit 680cd6db13

View File

@ -19,8 +19,9 @@ namespace NewHorizons.Handlers
_systems = systems; _systems = systems;
var shipLogRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas"); var shipLogRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
var reticleImage = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/");
if (shipLogRoot != null) if (shipLogRoot != null && reticleImage != null)
{ {
var starChartLog = new GameObject("StarChartMode"); var starChartLog = new GameObject("StarChartMode");
starChartLog.SetActive(false); starChartLog.SetActive(false);
@ -31,7 +32,7 @@ namespace NewHorizons.Handlers
ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>(); ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>();
var reticleImage = GameObject.Instantiate(SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform); GameObject.Instantiate(reticleImage, starChartLog.transform);
var scaleRoot = new GameObject("ScaleRoot"); var scaleRoot = new GameObject("ScaleRoot");
scaleRoot.transform.parent = starChartLog.transform; scaleRoot.transform.parent = starChartLog.transform;