Exemple #1
0
    //met à jour les positions des sliders sur l'interface
    private void UpdateSliders()
    {
        //Nettoyage des sliders
        foreach (BoxSlider slider in sliders)
        {
            Destroy(slider.gameObject);
        }
        sliders = new List <BoxSlider>();

        List <Vector2> keys = CurrentCurve.GetKeys();

        foreach (Vector2 key in keys)
        {
            GameObject   sliderObj = Instantiate(sliderPref, transform);
            BoxSliderKey boxSlider = sliderObj.GetComponent <BoxSliderKey>();
            sliderObj.SetActive(EditCurve);

            Vector2 keyScreen = CurveToScreen(key);
            boxSlider.ValueX        = keyScreen.x;
            boxSlider.ValueY        = keyScreen.y;
            boxSlider.editableCurve = this;

            sliders.Add(boxSlider);
        }
    }
Exemple #2
0
    //applique les modifs depuis le slider vers la courbe, et met a jour l'affichage
    public void UpdateCurveKey(BoxSlider changedSlider)
    {
        //tri de la liste des sliders, et conservation des indice avant et après le tri
        int oldId = sliders.IndexOf(changedSlider);

        sliders.Sort(CompSliders);
        int newId = sliders.IndexOf(changedSlider);

        if (oldId > newId)
        {
            int tmp = oldId;
            oldId = newId;
            newId = tmp;
        }
        for (int id = oldId; id <= newId; id++)
        {
            BoxSliderKey currentSlider = sliders[id].GetComponent <BoxSliderKey>();
            Vector2      keyPos        = ScreenToCurve(new Vector2(currentSlider.ValueX, currentSlider.ValueY));
            CurrentCurve.ChangeKeyById(id, keyPos);
        }
        UpdateLineRender();
    }