Exemple #1
0
    private void Start()
    {
        deleteBtn.onClick.AddListener(() => {
            GameUI.instance.ClearAllLine();
        });

        copyBtn.onClick.AddListener(() => {
            copyImg.gameObject.SetActive(!copyImg.gameObject.activeInHierarchy);
        });

        saveBtn.onClick.AddListener(() => {
            SavePhoto();
        });

        pencilBtn.onClick.AddListener(() => {
            GameUI.instance.paintInfo.color = selectItem.color;
            colorParent.gameObject.SetActive(true);
        });

        eraserBtn.onClick.AddListener(() => {
            GameUI.instance.paintInfo.color = Color.white;
            colorParent.gameObject.SetActive(false);
        });

        sizeSlider.onValueChanged.AddListener((float value) => {
            GameUI.instance.paintInfo.width = value;
        });
        sizeSlider.value = GameUI.instance.paintInfo.width;


        Util.DeleteChildren(colorParent);
        List <Color> colors = new List <Color>()
        {
            Util.ColorFromString("#ea4631"),
            Util.ColorFromString("#ffb820"),
            Util.ColorFromString("#4aed5a"),
            Util.ColorFromString("#32a3ea"),
            Util.ColorFromString("#8657ff"),
            Util.ColorFromString("#3a48ff"),
            Util.ColorFromString("#32e4ea"),
            Util.ColorFromString("#ea32a3"),
            Util.ColorFromString("#000000"),
            Util.ColorFromString("#ffffff")
        };

        for (int i = 0; i < colors.Count; i++)
        {
            ColorItem item = Instantiate(colorPrefab);
            item.SetContent(colors[i]);
            item.transform.SetParent(colorParent, false);
            if (i == 8)
            {
                selectItem = item;
            }
        }
    }