internal void OnInspectorGui(BGCurvePointI point, int index, BGCurveSettings settings)
        {
            var mode2D = point.Curve.Mode2D;


            //point transform
            if (point.Curve.PointsMode != BGCurve.PointsModeEnum.Inlined && point.PointTransform != null)
            {
                var referenceToPoint = BGCurveReferenceToPoint.GetReferenceToPoint(point);
                if (referenceToPoint == null)
                {
                    point.PointTransform.gameObject.AddComponent <BGCurveReferenceToPoint>().Point = point;
                }
            }

            BGEditorUtility.HorizontalBox(() =>
            {
                if (editorSelection != null)
                {
                    editorSelection.InspectorSelectionRect(point);
                }

                BGEditorUtility.VerticalBox(() =>
                {
                    BGEditorUtility.SwapLabelWidth(60, () =>
                    {
                        if (!settings.ShowPointPosition && !settings.ShowPointControlType)
                        {
                            BGEditorUtility.Horizontal(() =>
                            {
                                //nothing to show- only label
                                EditorGUILayout.LabelField("Point " + index);
                                PointButtons(point, index, settings);
                            });
                            BGEditorUtility.StartIndent(1);
                        }
                        else
                        {
                            //control type
                            if (settings.ShowPointControlType)
                            {
                                BGEditorUtility.Horizontal(() =>
                                {
                                    point.ControlType = (BGCurvePoint.ControlTypeEnum)EditorGUILayout.EnumPopup("Point " + index, point.ControlType);
                                    PointButtons(point, index, settings);
                                });
                                BGEditorUtility.StartIndent(1);
                            }

                            //position
                            if (settings.ShowPointPosition)
                            {
                                if (!settings.ShowPointControlType)
                                {
                                    BGEditorUtility.Horizontal(() =>
                                    {
                                        PositionField("Point " + index, point, mode2D, index);
                                        PointButtons(point, index, settings);
                                    });
                                    BGEditorUtility.StartIndent(1);
                                }
                                else
                                {
                                    PositionField("Pos", point, mode2D, index);
                                }
                            }
                        }
                    });

                    // control positions
                    if (point.ControlType != BGCurvePoint.ControlTypeEnum.Absent && settings.ShowPointControlPositions)
                    {
                        // 1st
                        ControlField(point, mode2D, 1);

                        // 2nd
                        ControlField(point, mode2D, 2);
                    }

                    //transform
                    if (settings.ShowTransformField)
                    {
                        BGEditorUtility.ComponentField("Transform", point.PointTransform, transform =>
                        {
                            if (transform != null)
                            {
                                Undo.RecordObject(transform, "Object moved");

                                if (point.Curve.PointsMode != BGCurve.PointsModeEnum.Inlined)
                                {
                                    Undo.AddComponent <BGCurveReferenceToPoint>(transform.gameObject).Point = point;
                                }
                            }

                            if (point.PointTransform != null)
                            {
                                var referenceToPoint = BGCurveReferenceToPoint.GetReferenceToPoint(point);
                                if (referenceToPoint != null)
                                {
                                    Undo.DestroyObjectImmediate(referenceToPoint);
                                }
                            }

                            point.PointTransform = transform;
                        });
                    }


                    //fields
                    if (point.Curve.FieldsCount > 0)
                    {
                        ShowFields(point);
                    }

                    BGEditorUtility.EndIndent(1);
                });
            });
        }
Esempio n. 2
0
        internal void OnInspectorGUI(BGCurvePoint point, int index, BGCurveSettings settings)
        {
            var maskField = point.Curve.Mode2DOn && Event.current.type == EventType.Repaint;

            BGEditorUtility.HorizontalBox(() =>
            {
                editorSelection.InspectorSelectionRect(point);
                BGEditorUtility.VerticalBox(() =>
                {
                    BGEditorUtility.SwapLabelWidth(60, () =>
                    {
                        if (!settings.ShowPointPosition && !settings.ShowPointControlType)
                        {
                            BGEditorUtility.Horizontal(() =>
                            {
                                EditorGUILayout.LabelField("Point " + index);
                                PointButtons(point, index, settings);
                            });
                            BGEditorUtility.StartIndent(1);
                        }
                        else
                        {
                            //control type
                            if (settings.ShowPointControlType)
                            {
                                BGEditorUtility.Horizontal(() =>
                                {
                                    point.ControlType = (BGCurvePoint.ControlTypeEnum)EditorGUILayout.EnumPopup("Point " + index, point.ControlType);
                                    PointButtons(point, index, settings);
                                });
                                BGEditorUtility.StartIndent(1);
                            }

                            //position
                            if (settings.ShowPointPosition)
                            {
                                var math          = editor.Editor.Math;
                                var positionWorld = math.GetPosition(index);

                                if (!settings.ShowPointControlType)
                                {
                                    BGEditorUtility.Horizontal(() =>
                                    {
                                        BGEditorUtility.Vector3Field("Point " + index, "Point's position in world space", positionWorld, vector3 => point.PositionWorld = vector3);
                                        if (maskField)
                                        {
                                            MaskFieldFor2D(point);
                                        }
                                        PointButtons(point, index, settings);
                                    });
                                    BGEditorUtility.StartIndent(1);
                                }
                                else
                                {
                                    BGEditorUtility.Vector3Field("Pos", "Point's position in world space", positionWorld, vector3 => point.PositionWorld = vector3);
                                    if (maskField)
                                    {
                                        MaskFieldFor2D(point);
                                    }
                                }
                            }
                        }
                    });

                    // control positions
                    if (point.ControlType != BGCurvePoint.ControlTypeEnum.Absent && settings.ShowPointControlPositions)
                    {
                        // 1st
                        BGEditorUtility.Vector3Field("Control 1", "Point 1st control position (local)", point.ControlFirstLocal, vector3 => { point.ControlFirstLocal = vector3; });
                        if (maskField)
                        {
                            MaskFieldFor2D(point);
                        }

                        // 2nd
                        BGEditorUtility.Vector3Field("Control 2", "Point 2nd control position (local)", point.ControlSecondLocal, vector3 => { point.ControlSecondLocal = vector3; });
                        if (maskField)
                        {
                            MaskFieldFor2D(point);
                        }
                    }

                    BGEditorUtility.EndIndent(1);
                });
            });
        }