public static void ShowField(BGCurvePointI point, BGCurvePointField field, Action <string, AnimationCurve> animationCurveCallback = null)
        {
            var name = point.Curve.IndexOf(field) + ") " + field.FieldName;

            switch (field.Type)
            {
            case BGCurvePointField.TypeEnum.Bool:
                BGEditorUtility.BoolField(name, point.GetField <bool>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.Int:
                BGEditorUtility.IntField(name, point.GetField <int>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.Float:
                BGEditorUtility.FloatField(name, point.GetField <float>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.Vector3:
                BGEditorUtility.Vector3Field(name, null, point.GetField <Vector3>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.Bounds:
                BGEditorUtility.BoundsField(name, point.GetField <Bounds>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.Color:
                BGEditorUtility.ColorField(name, point.GetField <Color>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.String:
                BGEditorUtility.TextField(name, point.GetField <string>(field.FieldName), v => point.SetField(field.FieldName, v), false);
                break;

            case BGCurvePointField.TypeEnum.AnimationCurve:
                BGEditorUtility.Horizontal(() =>
                {
                    BGEditorUtility.AnimationCurveField(name, point.GetField <AnimationCurve>(field.FieldName), v => point.SetField(field.FieldName, v));

                    if (animationCurveCallback != null && GUILayout.Button("Set", GUILayout.Width(40)))
                    {
                        animationCurveCallback(field.FieldName, point.GetField <AnimationCurve>(field.FieldName));
                    }
                });

                break;

            case BGCurvePointField.TypeEnum.Quaternion:
                BGEditorUtility.QuaternionField(name, point.GetField <Quaternion>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.GameObject:
                BGEditorUtility.GameObjectField(name, point.GetField <GameObject>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.Component:
                BGEditorUtility.ComponentChoosableField(name, point.GetField <Component>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.BGCurve:
                BGEditorUtility.BGCurveField(name, point.GetField <BGCurve>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;

            case BGCurvePointField.TypeEnum.BGCurvePointComponent:
                BGEditorUtility.Horizontal(() =>
                {
                    BGEditorUtility.BGCurvePointComponentField(name, point.GetField <BGCurvePointComponent>(field.FieldName), v => point.SetField(field.FieldName, v));
                    var currentPoint = point.GetField <BGCurvePointComponent>(field.FieldName);

                    if (currentPoint == null || currentPoint.Curve.PointsCount < 2)
                    {
                        return;
                    }

                    var indexOfField = currentPoint.Curve.IndexOf(currentPoint);

                    if (GUILayout.Button("" + indexOfField, GUILayout.Width(40)))
                    {
                        BGCurveChosePointWindow.Open(indexOfField, currentPoint.Curve, c => point.SetField(field.FieldName, c));
                    }
                });
                break;

            case BGCurvePointField.TypeEnum.BGCurvePointGO:
                BGEditorUtility.BGCurvePointGOField(name, point.GetField <BGCurvePointGO>(field.FieldName), v => point.SetField(field.FieldName, v));
                break;
            }
        }
예제 #2
0
            public void Ui(BGTableView ui)
            {
                var cursor = 0;

                // ==========================   First row
                //number
                ui.NextColumn("" + index, "Field's index", GetWidth(ui, ref cursor));

                //name
                ui.NextColumn(rect =>
                {
                    BGEditorUtility.TextField(rect, field.FieldName, s =>
                    {
                        if (NameHasError(field.Curve, s))
                        {
                            return;
                        }
                        Change(() => field.FieldName = s);
                    }, true);
                }, GetWidth(ui, ref cursor));

                //type
                ui.NextColumn(field.Type.ToString(), "Field's Type", GetWidth(ui, ref cursor));

                //show in Points menu
                ui.NextColumn(rect => BGEditorUtility.BoolField(rect, BGPrivateField.GetShowInPointsMenu(field), b => Change(() => BGPrivateField.SetShowInPointsMenu(field, b))),
                              GetWidth(ui, ref cursor));

                //delete icon
                ui.NextColumn(rect =>
                {
                    if (!GUI.Button(rect, deleteIcon) || !BGEditorUtility.Confirm("Delete", "Are you sure you want to delete '" + field.FieldName + "' field?", "Delete"))
                    {
                        return;
                    }

                    BGPrivateField.Invoke(field.Curve, BGCurve.MethodDeleteField, field, (Action <BGCurvePointField>)Undo.DestroyObjectImmediate);

                    GUIUtility.ExitGUI();
                }, GetWidth(ui, ref cursor));

                //\r\n
                ui.NextRow();

                // ==========================   Second row
                //does not support
                if (!SupportHandles(field.Type))
                {
                    return;
                }

                ui.NextColumn("      Handles", "Field's index", 25);

                //handles type
                ui.NextColumn(
                    rect => BGEditorUtility.PopupField(rect, (HandlesType)BGPrivateField.GetHandlesType(field), Type2Handles[field.Type],
                                                       b => Change(() => BGPrivateField.SetHandlesType(field, (int)((HandlesType)b)))), 30);

                //Handles color
                ui.NextColumn(rect => BGEditorUtility.ColorField(rect, BGPrivateField.GetHandlesColor(field), b => Change(() => BGPrivateField.SetHandlesColor(field, b))), 30);

                //show handles in Scene View
                ui.NextColumn(rect => BGEditorUtility.BoolField(rect, BGPrivateField.GetShowHandles(field), b => Change(() => BGPrivateField.SetShowHandles(field, b))), 5);

                //empty column under delete button
                ui.NextColumn(rect => EditorGUI.LabelField(rect, ""), 10);

                //\r\n
                ui.NextRow();
            }