예제 #1
0
 public void OnColorClick(PaletterButton btn)
 {
     if (this.activeButton == btn)
     {
         return;
     }
     if (btn.Completed && !PaletteController.ALLOW_SELECT_COMPLETED)
     {
         this.toastManager.ShowPaletteError(btn.Id + 1);
         return;
     }
     if (this.activeButton != null)
     {
         this.activeButton.Deselect();
     }
     this.activeButton = btn;
     this.activeButton.Select();
     if (this.positioner != null)
     {
         this.positioner.CheckFit(btn.Id);
     }
     if (this.NewColor != null)
     {
         this.NewColor(btn.Id);
     }
 }
예제 #2
0
 protected override void InternalInit(int id, Color color)
 {
     this.label.text         = (id + 1).ToString();
     this.label.color        = ((PaletterButton.Brightness(color) <= 130) ? Color.white : Color.black);
     this.imgColor.color     = color;
     this.completeMask.color = color;
 }
예제 #3
0
 public void Create(List <Color> colors)
 {
     this.Init();
     this.layout.Init(this.layoutConfig);
     this.buttons = new List <PaletterButton>();
     for (int i = 0; i < colors.Count; i++)
     {
         GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.btnPrefab);
         gameObject.transform.SetParent(this.layout.transform);
         gameObject.transform.localScale = Vector3.one;
         PaletterButton component = gameObject.GetComponent <PaletterButton>();
         component.Init(i, colors[i]);
         this.layout.AddElement((RectTransform)component.transform);
         this.buttons.Add(component);
     }
     this.positioner = this.layout.transform.parent.GetComponent <ScrollElementPositioner>();
     if (this.positioner != null)
     {
         List <Vector2> list = new List <Vector2>();
         Vector2        b    = new Vector2((float)this.layoutConfig.size / 2f, 0f);
         Vector2        b2   = new Vector2((float)this.layoutConfig.padding, 0f);
         for (int j = 0; j < this.buttons.Count; j++)
         {
             if (j == 0)
             {
                 list.Add(((RectTransform)this.buttons[j].transform).anchoredPosition - b2 - b);
             }
             else
             {
                 list.Add(((RectTransform)this.buttons[j].transform).anchoredPosition - b);
             }
         }
         this.positioner.Init(list, this.layoutConfig.padding, this.layoutConfig.spacing);
     }
 }