コード例 #1
0
    public override void OnInspectorGUI()
    {
        mgcurves = target as MGCurve;
        EditorGUI.BeginChangeCheck();

        colorCurve = EditorGUILayout.ColorField(colorCurve);
        if (selectedIndex >= 0 && selectedIndex < mgcurves.ControlPointCount)
        {
            DrawSelectedPointInspector();
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Point"))
        {
            Undo.RecordObject(mgcurves, "Add Point");
            mgcurves.AddCurve();
            EditorUtility.SetDirty(mgcurves);
        }
        if (GUILayout.Button("Loop", GUILayout.Width(50)))
        {
            Undo.RecordObject(mgcurves, "Loop");
            EditorUtility.SetDirty(mgcurves);
            mgcurves.Loop = true;
        }
        EditorGUILayout.EndHorizontal();
    }
コード例 #2
0
    private void OnSceneGUI()
    {
        mgcurves  = target as MGCurve;
        handleTr  = mgcurves.transform;
        handleRot = Tools.pivotRotation == PivotRotation.Local ?
                    handleTr.rotation : Quaternion.identity;

        Vector3 p0 = ShowPoint(0);

        for (int i = 1; i < mgcurves.ControlPointCount; i += 3)
        {
            Vector3 p1 = ShowPoint(i);
            Vector3 p2 = ShowPoint(i + 1);
            Vector3 p3 = ShowPoint(i + 2);

            Handles.color = Color.gray;
            Handles.DrawLine(p0, p1);
            Handles.DrawLine(p2, p3);

            Handles.DrawBezier(p0, p3, p1, p2, colorCurve, null, 2f);
            p0 = p3;
        }
    }