Пример #1
0
    ///////////////////////////////////////////////////////////////////
    /////////////////////       MeshViewer      ///////////////////////
    ///////////////////////////////////////////////////////////////////


    void GenerateMeshViewer(MotionPath Ge)
    {
        bool SameVert = Ge.IsSamePathVert();

        GUIStyle Font = new GUIStyle();

        Font.normal.textColor = Color.green;
        Font.alignment        = TextAnchor.MiddleCenter;
        Font.fontStyle        = FontStyle.Bold;
        Font.fontSize         = 18;

        if (!SameVert)
        {
            GUILayout.Label("Path의 모든 버텍스 갯수가 동일 해야 합니다", Font);
        }
        else
        {
            GUI.backgroundColor = new Color(0.75f, 0.75f, 0.75f);
            GUILayout.BeginVertical("GroupBox");
            GUILayout.Label(Ge.MeshFilter.mesh.vertices.Length.ToString() + " Verts, " + (Ge.MeshFilter.mesh.triangles.Length / 3).ToString() + " tris", Font);
            GUILayout.EndVertical();
            GUI.backgroundColor = GUI.color;

            EditorGUI.BeginChangeCheck();
            Ge.Debug_VertInfo = EditorGUILayout.Toggle("View VertIdx", Ge.Debug_VertInfo);
            if (Ge.Debug_VertInfo)
            {
                Ge.Debug_VertPos = EditorGUILayout.Toggle("View VertPos", Ge.Debug_VertPos);
            }
            Ge.Debug_DrawTriLine = EditorGUILayout.Toggle("View Tris", Ge.Debug_DrawTriLine);
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }



            EditorGUI.BeginChangeCheck();
            Ge.CreateMeshInfo.Count_Y = EditorGUILayout.IntSlider("Count_Y", Ge.CreateMeshInfo.Count_Y, 1, 10);
            if (GUILayout.Button("InvertUV_X"))
            {
                Ge.CreateMeshInfo.InvertUV_X = !Ge.CreateMeshInfo.InvertUV_X;
            }
            if (GUILayout.Button("InvertUV_Y"))
            {
                Ge.CreateMeshInfo.InvertUV_Y = !Ge.CreateMeshInfo.InvertUV_Y;
            }
            if (GUILayout.Button("FlipFace"))
            {
                Ge.CreateMeshInfo.FlipFace = !Ge.CreateMeshInfo.FlipFace;
            }
            bool ChangeMeshData = EditorGUI.EndChangeCheck();
            if (ChangeMeshData) //메쉬 관련 데이터 변경 시 메쉬 다시 구성
            {
                Ge.GenerateMesh(Ge.PathInfo.Count, Ge.CreateMeshInfo.Count_Y, Ge.PathInfo[0].VertexPos.Length);
            }

            if (GUILayout.Button("GenerateMesh (메쉬 생성)"))
            {
                Ge.GenerateMesh(Ge.PathInfo.Count, Ge.CreateMeshInfo.Count_Y, Ge.PathInfo[0].VertexPos.Length);
            }

            EditorGUI.BeginDisabledGroup(Ge.MeshFilter.mesh.vertices.Length == 0); //버튼 비활성화 조건
            {
                if (GUILayout.Button("Save Mesh"))
                {
                    Ge.SaveMesh(Ge.MeshFilter.mesh);
                }
            }
            EditorGUI.EndDisabledGroup();
        }
    }