Пример #1
0
    public override void OnInspectorGUI()
    {
        //DrawDefaultInspector();

        serializedObject.Update();

        EditorGUILayout.BeginHorizontal();
        m_toggleAddPoints = GUILayout.Toggle(m_toggleAddPoints, "Add Point", "button");

        if (GUILayout.Button("Remove Last Point"))
        {
            m_generator.RemoveLastPoint();
        }

        EditorGUILayout.EndHorizontal();

        if (m_generator.GetSamplesCount() == 0)
        {
            EditorGUILayout.LabelField("NEED REBUILD! SAMPLES COUNT IS 0!", EditorStyles.boldLabel);
            if (GUILayout.Button("Rebuild Mesh"))
            {
                m_generator.RebuildMesh();
            }
        }

        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("points"), true);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("lods"), true);

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("radius"));

        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(m_parameterMode);

        m_isParameterMode = m_parameterMode.enumValueIndex == 1;

        EditorGUI.BeginDisabledGroup(m_isParameterMode);
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("By Parameters", EditorStyles.boldLabel);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("sides"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("subdivision"));
        EditorGUI.EndDisabledGroup();

        EditorGUI.BeginDisabledGroup(!m_isParameterMode);
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("By Polycount", EditorStyles.boldLabel);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("triangles"));
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Spline Mode", EditorStyles.boldLabel);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("SplineMode"));
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Thickness", EditorStyles.boldLabel);

        EditorGUILayout.PropertyField(m_useThickness);

        EditorGUI.BeginDisabledGroup(!m_useThickness.boolValue);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("thickness"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("shellType"));
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("LOD's", EditorStyles.boldLabel);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("numberLODs"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("koeffLOD"));
        var list = m_generator.GetLODInfo();

        if (list.Count > 0)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("LOD's Info", EditorStyles.boldLabel);

            for (int i = 0; i < list.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(list[i].name);
                EditorGUILayout.LabelField(list[i].trisCount.ToString());
                EditorGUILayout.EndHorizontal();
            }
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("Build LOD's"))
        {
            m_generator.BuildLODs();
        }

        if (GUILayout.Button("Clear LOD's"))
        {
            m_generator.ClearLODs();
        }


        if (serializedObject.hasModifiedProperties)
        {
            serializedObject.ApplyModifiedProperties();
            m_generator.RebuildMesh();
        }
    }