Exemplo n.º 1
0
            // Instantiate Chart Holder
            public GameObject InstantiateInteractiveChartHolder(Transform parent, String name, List <int> markerPointIndices, List <Color> markerPointColors)
            {
                ChartObjectFactory      chartFactory         = FindObjectOfType <ChartObjectFactory>();
                GameObject              chart                = chartFactory.InstantiateChartHolder(parent, name);
                MarkerInteractableChart interactiveComponent = chart.AddComponent <MarkerInteractableChart>();

                interactiveComponent.MarkerIndexList = markerPointIndices;
                interactiveComponent.MarkerColorList = markerPointColors;
                return(chart);
            }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // Define x and y test data
        int   numOfSamples = 50;
        float spacing      = 0.5f;

        xData   = new float[numOfSamples];
        sinData = new float[numOfSamples];
        cosData = new float[numOfSamples];
        for (int i = 0; i < numOfSamples; ++i)
        {
            float x = i * spacing;
            xData[i]   = x;
            sinData[i] = Mathf.Sin(x);
            cosData[i] = Mathf.Cos(x);
        }

        // Chart factory
        ChartObjectFactory chartHolderFactory = FindObjectOfType <ChartObjectFactory>();

        // Instantiate chart game object
        chart = chartHolderFactory.InstantiateChartHolder(this.gameObject.transform, "ChartHolder");

        // Add Interactable component to the chart
        MarkerInteractableChart interactableComponent = chart.AddComponent <MarkerInteractableChart>();

        interactableComponent.MarkerIndexList.Add(0);         // marker at position X: 0
        interactableComponent.MarkerColorList.Add(Color.red); // marker color: red

        UpdateChartDisplay();

        // Configure slider
        slider          = GameObject.FindObjectOfType <Slider>();
        slider.minValue = 0;
        slider.maxValue = numOfSamples - 1;
        slider.value    = 0;
        slider.onValueChanged.AddListener(sliderChangedAction);
    }