Exemple #1
0
        private static bool NameHasError(BGCurve curve, string name)
        {
            var error = BGCurvePointField.CheckName(curve, name);

            if (error == null)
            {
                return(false);
            }

            BGEditorUtility.Inform("Error", error);
            return(true);
        }
        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;
            }
        }
Exemple #3
0
 public static void SetShowInPointsMenu(BGCurvePointField field, bool value)
 {
     Set(field, "showInPointsMenu", value);
 }
Exemple #4
0
 public static void SetHandlesColor(BGCurvePointField field, Color value)
 {
     Set(field, "handlesColor", value);
 }
Exemple #5
0
 public static void SetHandlesType(BGCurvePointField field, int value)
 {
     Set(field, "handlesType", value);
 }
Exemple #6
0
 public static void SetShowHandles(BGCurvePointField field, bool value)
 {
     Set(field, "showHandles", value);
 }
Exemple #7
0
 public static bool GetShowInPointsMenu(BGCurvePointField field)
 {
     return(Get <bool>(field, "showInPointsMenu"));
 }
Exemple #8
0
 public static Color GetHandlesColor(BGCurvePointField field)
 {
     return(Get <Color>(field, "handlesColor"));
 }
Exemple #9
0
 public static int GetHandlesType(BGCurvePointField field)
 {
     return(Get <int>(field, "handlesType"));
 }
Exemple #10
0
 //--------------------------------------- Fields
 public static bool GetShowHandles(BGCurvePointField field)
 {
     return(Get <bool>(field, "showHandles"));
 }
Exemple #11
0
 public PointField(BGCurvePointField field, int index, Texture2D deleteIcon)
 {
     this.field      = field;
     this.index      = index;
     this.deleteIcon = deleteIcon;
 }