Jump to content
Unity Insider Forum

Fruchtfolgeplan erstellen


peachplayer

Recommended Posts

hallo Leute

Kann mir jemand helfen? Ich möchte einen Fruchtfolgeplan machen und verwende dazu folgendes Script:

        if (graphData.Count > 10)
        {
            gap = 10.0f / graphData.Count;
        }

        float xIncrement = gap;   
		Vector3 startpoint = Vector3.zero;
        int i = 0;

        while (dataCount < graphData.Count)
        {

            Vector3 endpoint = new Vector3(graphData[dataCount].income * 0.01f, xIncrement + 8f, 0.96f);
            startpoint = new Vector3(0, endpoint.y, 0.96f);
            // pointer is an empty gameObject, i made a prefab of it and attach it in the inspector
            GameObject p = Instantiate(pointer, new Vector3(startpoint.x, startpoint.y, 0.97f), Quaternion.identity) as GameObject;
            p.transform.parent = holder.transform;
            // i made a prefab of it and attach it in the inspector
            GameObject lineObj = Instantiate(linerenderer, transform.position, Quaternion.identity) as GameObject;
            lineObj.transform.parent = holder.transform;
            lineObj.name = dataCount.ToString();


            LineRenderer lineRenderer = lineObj.GetComponent<LineRenderer>();

            lineRenderer.material = mat;
            lineRenderer.SetWidth(0.15F, 0.15F);
            lineRenderer.SetVertexCount(2);

            while (p.transform.position.y < endpoint.y)
            {
                p.transform.Translate(Vector3.up * Time.deltaTime * 8, Space.World);

                lineRenderer.SetPosition(0, startpoint);
                lineRenderer.SetPosition(1, p.transform.position);

            }

            lineRenderer.SetPosition(0, startpoint);
            lineRenderer.SetPosition(1, endpoint);

            p.transform.position = endpoint;

            startpoint = endpoint;
            dataCount++;

            if (FindParzellenname(graphData[dataCount].Parzellenname) == null)
                xIncrement = 0f;
            else if (FindParzellenname(graphData[dataCount].Parzellenname) != null)
                xIncrement += gap;

Leider werden die Linien bei gleichen Parzellennamen nicht fortgesetzt, sondern übereinander dargestellt. Weiss jemand weshalb?

Gruss, peachplayer

image.thumb.png.0d269b1a9d93976f103e3f66f7337bb8.png

Link zu diesem Kommentar
Auf anderen Seiten teilen

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Auf dieses Thema antworten...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Lädt...
×
×
  • Neu erstellen...