public virtual void Initialize(GenericDataPresenter presenter, GenericAxisView axisViewPrefab = null, GenericVisualizationStyle style = null)
        {
            if (presenter == null)
            {
                throw new ArgumentNullException("Presenter can't be null");
            }
            if (_presenter != null)
            {
                _presenter.DataUpdated -= Presenter_DataUpdated;
            }

            _initialized            = true;
            _fromEditor             = false;
            _presenter              = presenter;
            _presenter.DataUpdated += Presenter_DataUpdated;
            _axisViewPrefab         = axisViewPrefab;
            // if there is no axis prefab, there can be no axis views
            if (_axisViewPrefab == null)
            {
                _showAxes = false;
            }
            // Destroy initial axis views because references to axis presenters somehow gets lost
            // when started from the editor, so we just rebuild them completely
            DestroyAxisViews();
            _style = style;

            Rebuild_Internal();
        }
 public virtual void RebuildAxis()
 {
     if (_fromEditor)
         DestroyAxisView();
     if (_axisViewPrefab == null)
         return;
     if (_axisView == null)
     {
         _axisView = Instantiate(_axisViewPrefab, transform, false);
         _axisView.Length = _axisLength;
         _axisView.Swapped = _swapped;
         _axisView.Mirrored = _mirrored;
         _axisView.AxisPresenter = _presenter.AxisPresenters[_axisPresenterIndex];
     }
     var axis = _presenter.AxisPresenters[_axisPresenterIndex];
     AxisTick[] ticks;
     switch (_generationMethod)
     {
         default:
         case GenerationMethod.Dimension:
             ticks = axis.GenerateFromDimension(_presenter[_modeParam1], _presenter.SelectedMinItem, _presenter.SelectedMaxItem);
             break;
         case GenerationMethod.DimensionCaptions:
             ticks = axis.GenerateFromDimensionCaptions(_presenter, _modeParam1, _modeParam2);
             break;
         case GenerationMethod.DiscreteRange:
             ticks = axis.GenerateFromDiscreteRange(_modeParam1, _modeParam2);
             break;
         case GenerationMethod.MinMaxValue:
             ticks = axis.GenerateFromMinMaxValue(_min, _max);
             break;
     }
     _axisView.RebuildAxis(ticks);
 }
Beispiel #3
0
 protected virtual void DestroyAxisView()
 {
     if (_axisView != null)
     {
         DestroyImmediate(_axisView.gameObject);
     }
     _axisView = null;
 }
 /// <summary>
 /// Sets the prefab used for the axis views of this visualization.
 /// </summary>
 /// <param name="prefab">The axis view prefab.</param>
 protected virtual void SetAxisPrefab(GenericAxisView prefab)
 {
     if (_axisViewPrefab == prefab)
     {
         return;
     }
     _axisViewPrefab = prefab;
     if (!_initialized)
     {
         return;
     }
     SetupInitialAxisViews();
     RebuildAxes();
 }
 public virtual void Initialize(GenericDataPresenter presenter, GenericAxisView axisViewPrefab)
 {
     if (presenter == null)
         throw new ArgumentException("Presenter can't be null");
     _isInitialized = true;
     if (_presenter != null)
         _presenter.DataUpdated -= DataPresenter_DataUpdated;
     _presenter = presenter;
     _axisViewPrefab = axisViewPrefab;
     _fromEditor = false;
     if (_presenter != null)
         _presenter.DataUpdated += DataPresenter_DataUpdated;
     DestroyAxisView();
     RebuildAxis();
 }
Beispiel #6
0
 public virtual void Initialize(GenericDataPresenter presenter, GenericAxisView axisViewPrefab = null, GenericVisualizationStyle style = null, Mesh dataItemMesh = null)
 {
     _dataItemMesh = dataItemMesh;
     base.Initialize(presenter, axisViewPrefab, style);
 }