public void SetValueBounds(IStorableAnimationCurve storable, Rect valueBounds, bool normalizeToView = false, bool offsetToCenter = false) { // Ensure view matrix is up to date UpdateViewMatrix(); CurveLine line; if (!_storableToLineMap.TryGetValue(storable, out line)) { return; } var offset = offsetToCenter ? -valueBounds.min : Vector2.zero; if (normalizeToView) { line.drawScale = DrawScaleOffset.FromNormalizedValueBounds(valueBounds, GetViewBounds().size, offset); } else { line.drawScale = DrawScaleOffset.FromValueBounds(valueBounds, offset); } SetVerticesDirty(); }
public UICurveLine AddCurve(IStorableAnimationCurve storable, UICurveLineColors colors = null, float thickness = 4) { var lineContainer = new GameObject(); lineContainer.transform.SetParent(_linesContainer.transform, false); var rectTransform = _linesContainer.GetComponent <RectTransform>(); var line = lineContainer.AddComponent <UILine>(); line.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, rectTransform.sizeDelta.x); line.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, rectTransform.sizeDelta.y); line.lineThickness = thickness; var scrubberContainer = new GameObject(); scrubberContainer.transform.SetParent(_scrubbersContainer.transform, false); var scrubber = scrubberContainer.AddComponent <UIScrubber>(); scrubber.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1); scrubber.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, rectTransform.sizeDelta.y * 2); var curveLine = new UICurveLine(storable, line, scrubber, colors); _lines.Add(curveLine); _storableToLineMap.Add(storable, curveLine); _lineToContainerMap.Add(curveLine, lineContainer); BindPoints(curveLine); return(curveLine); }
public CurveLine(IStorableAnimationCurve storable, UICurveLineColors colors = null) { points = new List <CurveEditorPoint>(); _storable = storable; _colors = colors ?? new UICurveLineColors(); SetPointsFromCurve(); }
public void CreateCurve(IStorableAnimationCurve storable, UICurveLineColors colors, float thickness) { var line = new CurveLine(storable, colors); line.thickness = thickness; _lines.Add(line); _scrubberPositions.Add(line, line.curve.keys.First().time); _storableToLineMap.Add(storable, line); SetVerticesDirty(); }
public void SetScrubber(IStorableAnimationCurve storable, float time) { UICurveLine line; if (!_storableToLineMap.TryGetValue(storable, out line)) { return; } line.SetScrubber(time); }
public void UpdateCurve(IStorableAnimationCurve storable) { CurveLine line; if (!_storableToLineMap.TryGetValue(storable, out line)) { return; } line.SetPointsFromCurve(); SetVerticesDirty(); }
public void UpdateCurve(IStorableAnimationCurve storable) { UICurveLine line; if (!_storableToLineMap.TryGetValue(storable, out line)) { return; } line.SetPointsFromCurve(); BindPoints(line); }
public void SetScrubberPosition(IStorableAnimationCurve storable, float time) { CurveLine line; if (!_storableToLineMap.TryGetValue(storable, out line)) { return; } _scrubberPositions[line] = time; SetVerticesDirty(); }
public void RemoveCurve(IStorableAnimationCurve storable) { if (!_storableToLineMap.ContainsKey(storable)) { return; } var line = _storableToLineMap[storable]; _lines.Remove(line); _scrubberPositions.Remove(line); _storableToLineMap.Remove(storable); SetVerticesDirty(); }
public UICurveLine(IStorableAnimationCurve storable, UILine line, UIScrubber scrubber, UICurveLineColors colors = null) { points = new List <UICurveEditorPoint>(); _storable = storable; _line = line; _scrubber = scrubber; _colors = colors ?? new UICurveLineColors(); _evaluateCount = 200; _line.color = _colors.lineColor; _scrubber.color = _colors.scrubberColor; SetPointsFromCurve(); SetScrubber(0); }
public void RemoveCurve(IStorableAnimationCurve storable) { if (!_storableToLineMap.ContainsKey(storable)) { return; } var line = _storableToLineMap[storable]; _storableToLineMap.Remove(storable); _lines.Remove(line); var lineContainer = _lineToContainerMap[line]; _lineToContainerMap.Remove(line); GameObject.Destroy(lineContainer); }
public void SetValueBounds(IStorableAnimationCurve storable, Vector2 min, Vector2 max, bool normalizeToView = false, bool offsetToCenter = false) => _canvas.SetValueBounds(storable, min, max, normalizeToView, offsetToCenter);
public void SetValueBounds(IStorableAnimationCurve storable, Rect valueBounds, bool normalizeToView = false, bool offsetToCenter = false) => _canvas.SetValueBounds(storable, valueBounds, normalizeToView, offsetToCenter);
public void SetScrubber(IStorableAnimationCurve storable, float time) => _canvas.SetScrubberPosition(storable, time);
public void UpdateCurve(IStorableAnimationCurve storable) => _canvas.UpdateCurve(storable);
public void RemoveCurve(IStorableAnimationCurve storable) => _canvas.RemoveCurve(storable);
//TODO: meh... public void AddCurve(IStorableAnimationCurve storable, UICurveLineColors colors = null, float thickness = 0.04f) => _canvas.CreateCurve(storable, colors, thickness);
public void SetValueBounds(IStorableAnimationCurve storable, Vector2 valueMin, Vector2 valueMax, bool normalizeToView = false, bool offsetToCenter = false) => SetValueBounds(storable, new Rect(valueMin, valueMax - valueMin), normalizeToView, offsetToCenter);