Topic: uGUICustomMarkerEngineExample Crashing on Type Cast
I am trying to use the uGUICustomMarkerEngineExample but the script crashes from a null reference exception. In the AddMarkerAddMarker(double lng, double lat, string text) function the following code is causing this error:
public static uGUICustomMarkerExample AddMarker(double lng, double lat, string text)
{
GameObject markerGameObject = Instantiate(_instance.markerPrefab) as GameObject;
(markerGameObject.transform as RectTransform).SetParent(_instance.markerContainer);
...
}Casting markerGameObject.transform as RectTransform dynamically returns null and then calling .SetParent(...) on a null value crashed the script.
I tried attaching this script to the map object in the Demo Scene and set the markerPrefab and the markerContainer in the editor.
I also noted that markerGameObject.transform is a non-null Transform object prior to the cast. Is there any reason why this cast is returning null?
Tested this issue using Unity 5.4.1f1 and OnlineMaps versions 2.5.1.1 and 2.5.1.2