Exemple #1
0
    private void InitPallete()
    {
        Pickers = new List <ColorPicker>();
        ColorPicker firstPicker = null;
        float       width       = Level.Palette.Length * Configs.PALETTE_WIDTH;

        PallateContainer.GetComponent <RectTransform>().sizeDelta = new Vector2(width, 0);
        BoxCollider collider = PallateContainer.GetComponent <BoxCollider>();

        collider.size   = new Vector3(width, collider.size.y, collider.size.z);
        collider.center = new Vector3(width / 2f, collider.center.y, collider.center.z);
        for (int i = 0; i < Level.Palette.Length; i++)
        {
            GameObject  go          = Instantiate(ColorPickerPrefab);
            ColorPicker colorPicker = go.GetComponent <ColorPicker>();
            go.transform.SetParent(PallateContainer.transform);
            colorPicker.Init(Level.Palette[i], i + 1);
            if (firstPicker == null)
            {
                firstPicker = colorPicker;
            }
            Pickers.Add(colorPicker);
        }
        firstPicker.ColorPicked();

        // update all pickers
        UpdatePickerAll();
    }