Exemplo n.º 1
0
    private void DrawSplineInspector()
    {
        if (activeSpline >= 0)
        {
            GUILayout.Label("Spline:");
            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();
            string name = EditorGUILayout.TextField("Name", component.GetSplineName(activeSpline));
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(component, "Change spline name");
                EditorUtility.SetDirty(component);
                component.SetSplineName(activeSpline, name);
            }

            EditorGUI.BeginChangeCheck();
            SplineSettings settings = (SplineSettings)EditorGUILayout.ObjectField("Settings", component.GetSplineSettings(activeSpline), typeof(SplineSettings), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(component, "Change spline settings");
                EditorUtility.SetDirty(component);
                component.SetSplineSettings(activeSpline, settings);
            }

            EditorGUI.indentLevel--;
            EditorGUILayout.Space();

            if (settings != null)
            {
                GUILayout.Label("Active assets:");
                EditorGUI.indentLevel++;

                bool[] ActiveAssets = component.GetActiveAssets(activeSpline);
                EditorGUI.BeginChangeCheck();
                for (int i = 0; i < settings.generated.Count; i++)
                {
                    ActiveAssets[i] = EditorGUILayout.Toggle(settings.generated[i].name, ActiveAssets[i]);
                }
                for (int i = 0; i < settings.placers.Count; i++)
                {
                    ActiveAssets[i + settings.generated.Count] = EditorGUILayout.Toggle(settings.placers[i].name, ActiveAssets[i + settings.generated.Count]);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(component, "Change active assets");
                    EditorUtility.SetDirty(component);
                    component.SetActiveAssets(activeSpline, ActiveAssets);
                    ResetGeneratedContent();
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
    }