protected override void Edit(bool array)
    {
        DEditorGUI.WithLabel("Element Type",
                             () =>
        {
            PropertyType.ElementType = DEditorGUI.PropertyTypePopup(PropertyType.AllowedElementTypes,
                                                                    PropertyType.ElementType);
        });

        DEditorGUI.WithLabel("Element Count",
                             () => { PropertyType.ElementCount = Mathf.Max(2, EditorGUILayout.IntField(PropertyType.ElementCount)); });

        if (PropertyType.ElementType.HasSettings)
        {
            EditorGUILayout.BeginVertical();
            PropertyEditorRegistry.GetEditor(PropertyType.ElementType)
            .EditArrayElement(Asset, Definition, PropertyType.ElementType);
            EditorGUILayout.EndVertical();
        }
    }
    void EditProperty(AssetDefinition def, PropertyDefinition p, bool first, bool last)
    {
        BeginBackground();

        GUILayout.BeginHorizontal(DEditorGUI.HeaderBackground, GUILayout.Height(DEditorGUI.HEADER_HEIGHT));

        if ((Event.current.modifiers & EventModifiers.Control) == EventModifiers.Control)
        {
            if (DEditorGUI.IconButton("minus-editor"))
            {
                if (EditorUtility.DisplayDialog("Delete Property", string.Format("Do you want to delete '{0}' (Property)?", p.Name), "Yes", "No"))
                {
                    p.Deleted = true;
                }
            }
        }
        else
        {
            if (DEditorGUI.Toggle("arrow-down", "arrow-right", p.Expanded && (p.PropertyType.HasSettings || p.PropertyType.MecanimApplicable)))
            {
                p.Expanded = !p.Expanded;
            }
        }

        if (def is StateDefinition || def is ObjectDefinition)
        {
            p.Name = DEditorGUI.TextFieldOverlay(p.Name, p.Priority.ToString(), GUILayout.Width(181));

            switch (p.ReplicationMode)
            {
            case ReplicationMode.Everyone:
                DEditorGUI.Toggle("controller-plus", true);
                break;

            case ReplicationMode.EveryoneExceptController:
                DEditorGUI.Toggle("controller", false);
                break;

            case ReplicationMode.OnlyOwnerAndController:
                DEditorGUI.Toggle("controller-only", true);
                break;

            case ReplicationMode.LocalForEachPlayer:
                DEditorGUI.Toggle("owner-only", true);
                break;
            }
        }
        else
        {
            p.Name = EditorGUILayout.TextField(p.Name, GUILayout.Width(200));
        }

        DEditorGUI.SetTooltip("Name. The name of this property, has to be a valid C# property name.");

        // edit property type
        DEditorGUI.PropertyTypePopup(def, p);
        DEditorGUI.SetTooltip("Type. The type of this property.");

        EditorGUI.BeginDisabledGroup(def.SortOrder != SortOrder.Manual);

        if (DEditorGUI.IconButton("arrow-down", !last))
        {
            p.Adjust += 1;
        }

        if (DEditorGUI.IconButton("arrow-up", !first))
        {
            p.Adjust -= 1;
        }

        EditorGUI.EndDisabledGroup();
        EditorGUILayout.EndHorizontal();

        if (p.Controller)
        {
            p.ReplicationMode = ReplicationMode.Everyone;
            p.Controller      = false;
            Save();
        }

        if (p.Expanded)
        {
            GUILayout.Space(2);

            //DEditorGUI.WithLabel("Comment", () => {
            //  p.Comment = EditorGUILayout.TextField(p.Comment);
            //});

            if (def is StateDefinition || def is ObjectDefinition)
            {
                DEditorGUI.WithLabel("Replication", () =>
                {
                    p.Priority        = DEditorGUI.EditPriority(p.Priority, p.PropertyType.HasPriority);
                    p.ReplicationMode = (ReplicationMode)EditorGUILayout.EnumPopup(p.ReplicationMode);
                });
            }

            if (def is CommandDefinition)
            {
                if (p.PropertyType.CanSmoothCorrections && ((CommandDefinition)def).Result.Contains(p))
                {
                    DEditorGUI.WithLabel("Smooth Corrections", () =>
                    {
                        p.CommandAssetSettings.SmoothCorrection = EditorGUILayout.Toggle(p.CommandAssetSettings.SmoothCorrection);
                    });
                }
            }

            if (p.PropertyType.MecanimApplicable && (def is StateDefinition))
            {
                DEditorGUI.WithLabel("Mecanim", () =>
                {
                    EditorGUILayout.BeginHorizontal();

                    if (p.PropertyType is PropertyTypeFloat)
                    {
                        p.StateAssetSettings.MecanimMode = (MecanimMode)EditorGUILayout.EnumPopup(p.StateAssetSettings.MecanimMode);
                        EditorGUI.BeginDisabledGroup(p.StateAssetSettings.MecanimMode == MecanimMode.Disabled);

                        p.StateAssetSettings.MecanimDirection = (MecanimDirection)EditorGUILayout.EnumPopup(p.StateAssetSettings.MecanimDirection);

                        switch (p.StateAssetSettings.MecanimMode)
                        {
                        case MecanimMode.Parameter:
                            if (p.StateAssetSettings.MecanimDirection == MecanimDirection.UsingAscensionProperties)
                            {
                                p.StateAssetSettings.MecanimDamping = DEditorGUI.FloatFieldOverlay(p.StateAssetSettings.MecanimDamping, "Damping Time");
                            }

                            break;

                        case MecanimMode.LayerWeight:
                            p.StateAssetSettings.MecanimLayer = DEditorGUI.IntFieldOverlay(p.StateAssetSettings.MecanimLayer, "Layer Index");
                            break;
                        }

                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        p.StateAssetSettings.MecanimMode = (MecanimMode)(int)EditorGUILayout.Popup((int)p.StateAssetSettings.MecanimMode, new string[] { "Disabled", "Parameter" });

                        EditorGUI.BeginDisabledGroup(p.StateAssetSettings.MecanimMode == MecanimMode.Disabled);
                        p.StateAssetSettings.MecanimDirection = (MecanimDirection)EditorGUILayout.EnumPopup(p.StateAssetSettings.MecanimDirection);

                        if (p.PropertyType is PropertyTypeTrigger)
                        {
                            p.StateAssetSettings.MecanimLayer = DEditorGUI.IntFieldOverlay(p.StateAssetSettings.MecanimLayer, "Layer Index");
                        }
                        EditorGUI.EndDisabledGroup();
                    }

                    EditorGUILayout.EndHorizontal();
                });
            }

            if (p.PropertyType.HasSettings)
            {
                PropertyEditorRegistry.GetEditor(p.PropertyType.GetType()).Edit(def, p);
            }
        }
        else
        {
            GUILayout.Space(2);
        }

        EditorGUILayout.EndVertical();
    }