private void OnInitialize() { GUILayout vertLayout = GUI.AddLayoutY(); GUILayout editorPanel = vertLayout.AddPanel(GUIOption.FixedHeight(400)); GUILayout buttonLayout = vertLayout.AddLayoutX(GUIOption.FixedHeight(40)); guiOK = new GUIButton(new LocEdString("OK")); guiCancel = new GUIButton(new LocEdString("Cancel")); guiOK.OnClick += OnOK; guiCancel.OnClick += OnCancel; CurveDrawOptions drawOptions = CurveDrawOptions.DrawKeyframes | CurveDrawOptions.DrawMarkers; if (curveB != null) { drawOptions |= CurveDrawOptions.DrawRange; } curveEditor = new GUICurveEditor(editorPanel, 600, 400, false, drawOptions); curveEditor.Redraw(); EdCurveDrawInfo[] drawinfo; if (curveB != null) { drawinfo = new [] { new EdCurveDrawInfo(curveA, Color.BansheeOrange), new EdCurveDrawInfo(curveB, Color.Green), }; } else { drawinfo = new [] { new EdCurveDrawInfo(curveA, Color.BansheeOrange), }; } curveEditor.SetCurves(drawinfo); curveEditor.CenterAndResize(true); buttonLayout.AddFlexibleSpace(); buttonLayout.AddElement(guiOK); buttonLayout.AddSpace(10); buttonLayout.AddElement(guiCancel); buttonLayout.AddFlexibleSpace(); EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; }
private void OnInitialize() { // TODO - Add methods to allow the window to be open with user-defined curve(s) // TODO - Add callbacks that trigger when user finishes editing // TODO - Add OK/Cancel buttons? Make the window modal? // TODO - Add a CurveField GUI element that can be used for curve preview, clicking on which opens this window curveEditor = new GUICurveEditor(this, this.GUI, 600, 400, false); curveEditor.Redraw(); EdAnimationCurve[] edAnimCurve = { new EdAnimationCurve(), new EdAnimationCurve() }; edAnimCurve[0].AddKeyframe(0.0f, 1.0f); edAnimCurve[0].AddKeyframe(5.0f, 3.0f); edAnimCurve[0].AddKeyframe(8.0f, -3.0f); edAnimCurve[0].AddKeyframe(15.0f, 2.0f); edAnimCurve[0].Apply(); edAnimCurve[1].AddKeyframe(0.0f, -3.0f); edAnimCurve[1].AddKeyframe(3.0f, 0.0f); edAnimCurve[1].AddKeyframe(10.0f, -1.0f); edAnimCurve[1].AddKeyframe(13.0f, -5.0f); edAnimCurve[1].Apply(); CurveDrawInfo[] drawinfo = { new CurveDrawInfo(edAnimCurve[0], Color.Green), new CurveDrawInfo(edAnimCurve[1], Color.Red), }; curveEditor.SetCurves(drawinfo); curveEditor.CenterAndResize(true); curveEditor.SetDrawRange(true); EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; }