1 (edited by gamar 2016-08-24 10:53:20)

Topic: Null reference on clicking a marker

Unity version - 5.1.4f1
iOS version - 9.3.4
Android version - 4.3
(I think phone/os is irrelevant in this matter)
Maps version - 2.5.0.3 (is a beta version I know, but I need it for another feature that only exists in the beta)

When I tap on a marker I get this null pointer exception.

Marker 1 is "selected" and when I tap on marker 4 I want to selected it. I delete a line while doing this and I get this crash which messes my flow of execution.

It only reproduces once. After that the map needs to be reloaded to be reproduced.

I can provide any info that you need further on. Can you please help? Thank you!

http://i.imgur.com/SI3MPjM.png
http://i.imgur.com/LO6sXQ3.png

Re: Null reference on clicking a marker

Hello.

It looks as if you are deleting points of line instead of a line.
Please show the code where you are removing the line.

Of course, this is also an issue and it will be checked and fixed.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

3 (edited by gamar 2016-08-24 14:08:40)

Re: Null reference on clicking a marker

Sure. Each pin has an index attached. When I tap I just call ShowStory(pinIndex).

private void ShowStory (int index)
        {
            if (index < 0)
                return;

            m_onlineMaps.markers [m_currentArtifactIndex].zIndex = m_currentArtifactIndex;
            m_onlineMaps.markers [m_currentArtifactIndex].scale = m_artifactsActions [m_currentArtifactIndex].Scale;

            ActivityAction marker = m_artifactsActions [index];
            m_storiesCarousel.CenterOnChild (index, false);

            if (ComputeDirectionsFromUser (index)) {
                Vector2 center;
                int zoom;
                OnlineMapsUtils.GetCenterPointAndZoom (new Vector2[2] {
                    marker.Position.Value,
                    m_userPosition.Value
                }, out center, out zoom);
                m_onlineMaps.SetPositionAndZoom (center.x, center.y, zoom - 1);
            } else {
                m_onlineMaps.SetPosition (marker.Position.Value.x, marker.Position.Value.y);
            }

            if (m_currentArtifactIndex >= 0)
                m_onlineMaps.markers [m_currentArtifactIndex].scale = m_artifactsActions [m_currentArtifactIndex].Scale;
            m_onlineMaps.markers [index].scale = marker.Scale * m_selectedPinSize;

            if (!m_isStoryShowing) {
                m_isStoryShowing = true;
                m_storiesContainer.GetComponent<Animator> ().SetTrigger ("Show");
                ToolsController.Instance.OnlineMapsController.SlideLeft (true);
            }

            m_onlineMaps.markers [index].zIndex = -1;

            CheckGoToArtifactAvailability (index);

            m_currentArtifactIndex = index;
            m_onlineMaps.Redraw ();
        }

        private bool ComputeDirectionsFromUser (int artifactIndex)
        {
            ActivityAction marker = m_artifactsActions [artifactIndex];
            if (m_artifacts [artifactIndex].State != ArtifactState.Locked && IsUserCloseTo (marker.Position.Value, m_directionsRadius)) {
                StartCoroutine (ComputeDirectionsFromUser (marker.Position.Value));
                return true;
            } else {
                if (m_userDirectionLine != null)
                    m_onlineMaps.RemoveDrawingElement (m_userDirectionLine);//this is where I remove the line
                return false;
            }
        }

Re: Null reference on clicking a marker

I just saw that you have a very strange stack trace.
In the original code HitTest is not used in InitLineMesh.
You have modified this method?

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Null reference on clicking a marker

Ok...this is weird...I haven't modified that method at all yet that is the error that I get.

I have taken another screenshot from another device and have a different stacktrace. I tracked it and the function exists this time(Horaay!)

http://i.imgur.com/wwl27mW.png

Re: Null reference on clicking a marker

You have points == null.
This can happen in three cases:
1. You create a drawing element (line, poly) with points = null;
2. You set points = null;
3. You add drawing element, remove it, and add again.
By default, when you remove drawing element, it dispose.
To prevent this, use OnlineMaps.RemoveDrawingElement (element, false).

In the next update, when you try to use points = null (in all three cases), you'll get an exception immediately.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Null reference on clicking a marker

yup...that fixed it. Thanks!