2
\$\begingroup\$

I have a typical foreach loop in a coroutine like:

    foreach (DLine LineItem in DLINEs)
    {
        GameObject NL = GameObject.Instantiate(DXFLine);
        NL.layer = LayerMask.NameToLayer("2D");
        LineRenderer NLLR = NL.GetComponent();
        NLLR.positionCount = (2);
        NLLR.startWidth = (0.01f); NLLR.endWidth = (0.01f);
        Color LineColor = new Color();
        DLAYER DL = TABLES.DLAYARs.FirstOrDefault(l => l.LayerName == LineItem.Layer);
        if ((LineItem.ColorNumber == -1395 || LineItem.ColorNumber == 256) && DL != null)
            LineColor = COLORs[DL.ColorNumber];
        else if ((LineItem.ColorNumber != -1395 && LineItem.ColorNumber != 256))
            LineColor = COLORs[LineItem.ColorNumber];
        if (LineColor == Color.clear) LineColor = new Color(1.0f, 1.0f, 1.0f);
            NLLR.startColor = LineColor;
        NLLR.endColor = LineColor;
>       NLLR.SetPosition(0, LineItem.StartPoint.ToVector3());
>       NLLR.SetPosition(1, LineItem.EndPoint.ToVector3());
        NL.name = "LINE-" + LineItem.Handle;
        NL.transform.SetParent(Lines.transform);
        DXF_Input.DXFLines.Add(NLLR);
        //Debug.Log(item.Log());
        Counter++;
        if (Counter == 50)
        {
             Counter = 0;
             yield return WFS;
        }
    }

and I want to debug it using Visual studio by putting breakepoint on the lines with '>'. I'm running unity and attaching the VS to unity and it stops at the breakpoint so there is no problem there. But when I want to see the values, it says the Identifier LineItem is not in the scope.
Why is this happening?
How can I fix it?

\$\endgroup\$
  • 3
    \$\begingroup\$ could you post more of the code and where exactly you are putting the breakpoint. A screenshot even might help. \$\endgroup\$ – Uri Popov Nov 7 '17 at 10:03
  • \$\begingroup\$ @UriPopov added the code. \$\endgroup\$ – Henjin Nov 8 '17 at 4:58
  • \$\begingroup\$ You should not add so much code into the foreach loop, put it in functions and then call them inside the loop, thats cleaner... I think you get this message because LineItem is of Type LineRenderer which is a public sealed class and I think it is defined in a DLL file \$\endgroup\$ – Black Nov 8 '17 at 13:26
  • \$\begingroup\$ @Black Thanks for the advise about the functions. LineItem is of a custom class that has information about the line. and that is not in a dll or such \$\endgroup\$ – Henjin Nov 8 '17 at 13:50