コード例 #1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        meshEditor = target as MeshEditor;

        if (meshEditor == null)
        {
            return;
        }

        if (GUILayout.Button("Load mesh"))
        {
            meshEditor.LoadMesh();
        }

        if (GUILayout.Button("Add vertex"))
        {
            meshEditor.AddVertex();
        }

        int numberOfTriangles = meshEditor.GetNumberOfTriangles();

        GUILayout.BeginVertical();
        EditorGUILayout.Space();

        for (int i = 0; i < meshEditor.vertexData.Count; i++)
        {
            meshEditor.vertexData[i] = ShowVertexEditUI(meshEditor.vertexData[i], i);
        }

        if (GUILayout.Button("Add triangle"))
        {
            meshEditor.AddTriangle();
        }

        for (int t = 0; t < meshEditor.triangleData.Count; t++)
        {
            meshEditor.triangleData[t] = ShowTriangleEditUI(meshEditor.triangleData[t]);

            meshEditor.vertexData[meshEditor.triangleData[t].vertexId0].triangleIndex = t;
            meshEditor.vertexData[meshEditor.triangleData[t].vertexId0].triangleOrder = 0;

            meshEditor.vertexData[meshEditor.triangleData[t].vertexId1].triangleIndex = t;
            meshEditor.vertexData[meshEditor.triangleData[t].vertexId1].triangleOrder = 1;

            meshEditor.vertexData[meshEditor.triangleData[t].vertexId2].triangleIndex = t;
            meshEditor.vertexData[meshEditor.triangleData[t].vertexId2].triangleOrder = 2;
        }

        if (GUILayout.Button("Generate Mesh"))
        {
            meshEditor.GenerateMesh();
        }

        Tools.hidden = selectedVertexIndex != -1;
    }