<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Null Error on AddMarker]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=843&amp;type=atom" />
	<updated>2018-05-22T16:40:02Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=843</id>
		<entry>
			<title type="html"><![CDATA[Re: Null Error on AddMarker]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3616#p3616" />
			<content type="html"><![CDATA[<p>Alex,</p><p>Thanks for the info! I used option 1 and set it as public and put the map into the inspector and that solved the issue!</p><p>Cheers,</p><p>Neil</p>]]></content>
			<author>
				<name><![CDATA[AppFreak]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=708</uri>
			</author>
			<updated>2018-05-22T16:40:02Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3616#p3616</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Null Error on AddMarker]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3613#p3613" />
			<content type="html"><![CDATA[<p>OnlineMaps.instance is not available in Awake and OnEnable.<br />This is available in Start or later.</p><p>There are many ways to solve this problem:<br />1. Make the map field public, and set the field using the inspector.<br />2. Make a map property instead of the field that will return OnlineMaps.instance.<br />3. Call OnlineMaps.instance directly.<br />4. Make MapControl.Init method, which will be called at the beginning of CCTVFileLoader.Start, and will set the correct reference to the map.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-05-21T23:33:06Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3613#p3613</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Null Error on AddMarker]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3607#p3607" />
			<content type="html"><![CDATA[<p>Hello.</p><p>If you are asking about errors in your script, attach the entire script.<br />I do not know what&#039;s in line 148 and 193 of your script.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-05-21T20:10:32Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3607#p3607</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Null Error on AddMarker]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3606#p3606" />
			<content type="html"><![CDATA[<p>I am using multiple scripts to access the map and originally I had the map/marker definition in each script as private, but when I did a OnMarkerClick there appeared to be7 bleed over between the scripts. I could tell this because each script added a different colored marker teture but when I clicked a specific color it waould use code from a differnt script. Hopefully this is somewhat clear.</p><p>What I did was move all the map code to one script and access this using an Instance of that script MapControls.Instance.SetMarkers... for example.</p><p>Now when I use one script to call the other to do an AddMarker, I get a Null Error. I have debugs that show all the fields contain the right data so not sure what is goin on. Below is the error then the code including debug results:</p><br /><p>========== Error Begin</p><p>NullReferenceException: Object reference not set to an instance of an object<br />MapControls.SwitchFunctions (System.String func) (at Assets/_Scripts/MapControls.cs:148)<br />MapControls.Awake () (at Assets/_Scripts/MapControls.cs:59)</p><br /><p>========== Error End</p><br /><br /><p>========== MapControls Script Code</p><p>Map/Marker Definition:</p><p>private OnlineMaps map;<br />&nbsp; &nbsp; <br />private OnlineMapsMarker marker;</p><p>Add Markers Script:</p><p>public void SetMarkers(double tempLng, double tempLat, Texture2D tempTex, string tempLabel) {</p><br /><p>&nbsp; &nbsp; Debug.Log(&quot; &quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; Debug.Log(&quot;SetMarkers - lng: &quot; + tempLng + &quot; lat: &quot; + tempLat);</p><p>&nbsp; &nbsp; Debug.Log(&quot;SetMarkers - Texture: &quot; + tempTex.name);</p><p>&nbsp; &nbsp; Debug.Log(&quot;SetMarkers - Label: &quot; + tempLabel);</p><br /><p>&nbsp; &nbsp; //// Actual Debug Results:<br />&nbsp; &nbsp; SetMarkers - lng: -120.071841 lat: 39.26079</p><p>&nbsp; &nbsp; SetMarkers - Texture: MarkerTextures_Blue</p><p>&nbsp; &nbsp; SetMarkers - Label: Hwy 267 at Brockway Summit</p><p>&nbsp; &nbsp; ////</p><p>&nbsp; &nbsp; map.AddMarker(tempLng, tempLat, tempTex, tempLabel);</p><br /><p>}</p><p>========== End Of MapControls Script Code</p><br /><br /><p>========== Calling Script Code</p><p>&nbsp; &nbsp; double tempLng = double.Parse(tempRow.longitude.ToString());</p><p>&nbsp; &nbsp; double tempLat = double.Parse(tempRow.latitude.ToString());</p><br /><p>&nbsp; &nbsp; Debug.Log(&quot;LoadCADistrict - lng: &quot; + tempLng + &quot; lat: &quot; + tempLat);</p><p>&nbsp; &nbsp; Debug.Log(&quot;LoadCADistrict - Texture: &quot; + markerTexture.name);</p><p>&nbsp; &nbsp; Debug.Log(&quot;LoadCADistrict - Label: &quot; + tempRow.locationName);</p><br /><p>&nbsp; &nbsp; //// Actual Debug Results:<br />&nbsp; &nbsp; LoadCADistrict - lng: -120.071841 lat: 39.26079</p><p>&nbsp; &nbsp; LoadCADistrict - Texture: MarkerTextures_Blue</p><p>&nbsp; &nbsp; LoadCADistrict - Label: Hwy 267 at Brockway Summit</p><p>&nbsp; &nbsp; ////</p><p>&nbsp; &nbsp; MapControls.Instance.SetMarkers(tempLng, tempLat, markerTexture, tempRow.locationName);</p><br /><br /><p>========== End Of Calling Script Code</p><br /><br /><p>Update: I Changed the call to feed actual data to the MapControls.SetMarkers function and now I ge the follwoing error:</p><p>======== Begin Error</p><p>NullReferenceException: Object reference not set to an instance of an object<br />MapControls.SetMarkers (Double tempLng, Double tempLat, UnityEngine.Texture2D tempTex, System.String tempLabel) (at Assets/_Scripts/MapControls.cs:193)<br />CCTVFileLoader.LoadCADistrict () (at Assets/_Scripts/CCTVFileLoader.cs:851)<br />CCTVFileLoader.StartMeUpCCTV () (at Assets/_Scripts/CCTVFileLoader.cs:86)<br />CCTVFileLoader.Start () (at Assets/_Scripts/CCTVFileLoader.cs:78)</p><p>========= End Error</p>]]></content>
			<author>
				<name><![CDATA[AppFreak]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=708</uri>
			</author>
			<updated>2018-05-21T17:45:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3606#p3606</id>
		</entry>
</feed>
