<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Null Error on AddMarker]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=843</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=843&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Null Error on AddMarker.]]></description>
		<lastBuildDate>Tue, 22 May 2018 16:40:02 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Null Error on AddMarker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3616#p3616</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (AppFreak)]]></author>
			<pubDate>Tue, 22 May 2018 16:40:02 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3616#p3616</guid>
		</item>
		<item>
			<title><![CDATA[Re: Null Error on AddMarker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3613#p3613</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 21 May 2018 23:33:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3613#p3613</guid>
		</item>
		<item>
			<title><![CDATA[Re: Null Error on AddMarker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3607#p3607</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 21 May 2018 20:10:32 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3607#p3607</guid>
		</item>
		<item>
			<title><![CDATA[Null Error on AddMarker]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3606#p3606</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (AppFreak)]]></author>
			<pubDate>Mon, 21 May 2018 17:45:18 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3606#p3606</guid>
		</item>
	</channel>
</rss>
