Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        bool changed = false;
        int  old     = this.cubicBezier.segments;

        this.cubicBezier.segments = EditorGUILayout.IntSlider(this.cubicBezier.segments, 1, 1000);
        if (old != this.cubicBezier.segments)
        {
            changed = true;
        }


        newOffset       = EditorGUILayout.FloatField("New Offset Value", newOffset);
        newHeightOffset = EditorGUILayout.FloatField("New Offset Value", newHeightOffset);
        if (GUILayout.Button("Add new Offset"))
        {
            this.cubicBezier.offsets.Add(new Vector2(newOffset, newHeightOffset));
        }

        float oldValue = cubicBezier.width;
        float newValue = GUILayout.HorizontalSlider(cubicBezier.width, 0f, 20f);

        if (oldValue != newValue)
        {
            cubicBezier.width = newValue;
            cubicBezier.offsets.Clear();
            cubicBezier.offsets.Add(new Vector2(-cubicBezier.width * 0.5f, 0f));
            cubicBezier.offsets.Add(new Vector2(cubicBezier.width * 0.5f, 0f));
            cubicBezier.GenerateMesh();
        }

        bool oldBoolValue = cubicBezier.isLine;
        bool newBoolValue = EditorGUILayout.Toggle("Is Line", oldBoolValue);

        if (oldBoolValue != newBoolValue)
        {
            cubicBezier.isLine = newBoolValue;

            if (cubicBezier.isLine)
            {
                cubicBezier.offsets.Clear();
                cubicBezier.offsets.Add(new Vector2(-cubicBezier.width * 0.5f, 0f));
                cubicBezier.offsets.Add(new Vector2(cubicBezier.width * 0.5f, 0f));
            }
            cubicBezier.GenerateMesh();
        }


        if (GUILayout.Button("Make Street"))
        {
            this.cubicBezier.offsets.Clear();

            float akku = 0;

            // Mittelstreifen
            this.cubicBezier.offsets.Add(new Vector2(akku, 0.4f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.4f, 0.35f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.7f, 0.12f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.12f, 0.12f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.03f, 0.00f));

            //Straße
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.25f, 0.04f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 2.5f, 0.1f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 2.5f, 0.04f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.25f, 0.0f));

            // Parkstreifen mit Bordstein
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.05f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.06f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 1.85f, 0.06f));

            // Zwischenstreifen mit Bordstein
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.16f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.18f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.60f, 0.18f));

            // Radweg
            this.cubicBezier.offsets.Add(new Vector2(akku += 1.6f, 0.2f));

            // Fußgänger
            this.cubicBezier.offsets.Add(new Vector2(akku += 4f, 0.3f));

            //Downward
            this.cubicBezier.offsets.Add(new Vector2(akku, -3f));


            akku = -akku;
            this.cubicBezier.offsets.Add(new Vector2(akku, -3f));
            this.cubicBezier.offsets.Add(new Vector2(akku, 0.3f));

            // Fußgänger
            this.cubicBezier.offsets.Add(new Vector2(akku += 4f, 0.2f));
            // Radweg
            this.cubicBezier.offsets.Add(new Vector2(akku += 1.6f, 0.18f));

            // Zwischenstreifen mit Bordstein
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.60f, 0.18f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.16f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.06f));


            // Parkstreifen mit Bordstein
            this.cubicBezier.offsets.Add(new Vector2(akku += 1.85f, 0.06f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.05f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.075f, 0.0f));

            //Straße
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.25f, 0.04f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 2.5f, 0.1f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 2.5f, 0.04f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.25f, 0.00f));

            // Mittelstreifen
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.03f, 0.12f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.12f, 0.12f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.7f, 0.35f));
            this.cubicBezier.offsets.Add(new Vector2(akku += 0.4f, 0.4f));
            //this.cubicBezier.offsets.Add(new Vector2(akku, 0.0f));



            changed = true;
        }


        if (changed)
        {
            cubicBezier.RecalculateCurve();
        }

//		if(GUILayout.Button("")) {
//
//		}

        if (GUI.changed)
        {
            EditorUtility.SetDirty(cubicBezier);
        }
    }