public void Initialize(PatientJournalScreen.GraphData[] datas, bool createMesh, bool useSmoothGraph, int maxValue, int daysToShow, int numOfLabels) { _graphPoints.Clear(); _totalWidth = datas.Length; for (int i = 0; i < datas.Length; i++) { if (!datas[i].dontUseInGraph) { _graphPoints.Add(new Vector3(i, datas[i].interpolatedScore, 0)); } } _maxValue = maxValue; UpdateLabels(_maxValue, numOfLabels); if (_graphPoints.Count < 2) { return; } _daysToShow = daysToShow; // orthographic size must fit to max value _camera.orthographicSize = _maxValue / 2f; // and define width by setting proper aspect to cover all days to show _camera.aspect = (float)_daysToShow / _maxValue; // update camera position _camera.transform.localPosition = new Vector3(0, _camera.orthographicSize, -1); // setup GraphRenderer before assigning the texture _graphRenderer.UpdateGraph(_graphPoints, createMesh, useSmoothGraph, _daysToShow, _maxValue); // set new texture _camera.targetTexture = _graphRenderer.GetRenderTexture(); _graphImage.texture = _graphRenderer.GetRenderTexture(); }