public int FindElement(UICache elem) { for (int n = 0, cnt = this.ElementsCount; n < cnt; ++n) { if (elem == this.elems[n]) { return(n); } } return(-1); }
public static void OptimizeAnimPairOnetime(UICache cache) { if (!cache) { return; } if (cache.isOptimizedAnimPair) { return; } cache.OptimizeAnimPair(); }
protected virtual void SetSprite(UICache co, int spriteIndex) { if (!co.Graphic) { return; } if (!this.sprites) { return; } if (co.Graphic.TrySetSprite(this.sprites[spriteIndex])) { co.Graphic.SetNativeSize(); } }
protected virtual void SetSprite(UICache co, uint number) { if (!co.Graphic) { return; } if (!this.sprites) { return; } if (this.autoNativeSize) { co.Graphic.SetNativeSize(); } co.Graphic.TrySetSprite(this.sprites[(int)number]); }
public bool InsertElement(int index, UICache elem) { if (this.ContainsElement(elem)) { return(false); } if (0 > index) { index = 0; } if (index >= this.ElementsCount) { this.elems.Add(elem); } else { this.elems.Insert(index, elem); } return(true); }
public bool RemoveElement(UICache elem) { return(this.RemoveElementAt(this.FindElement(elem))); }
public bool ContainsElement(UICache elem) { return(-1 != this.FindElement(elem)); }
public void SetValue(uint value) { this.isFirst = false; if (0 == this.ElementsCount) { this.value = 0; this.ValueCount = 0; this.ZeroCount = 0; this.Rebuild(); return; } this.value = value; this.ValueCount = (0 == value) ? 1 : (int)NumberBox.CalcDigitCount(value); this.ZeroCount = 0; #if UNITY_EDITOR this.editorTestValue = this.value; #endif// UNITY_EDITOR if (this.ElementsCount < this.ValueCount) { // fill to 999999... this.ValueCount = this.ElementsCount; this.value = 9; for (int digit = 0; digit < this.ElementsCount; ++digit) { this.value *= 10; this.value += 9; var co = this.Elements[digit]; if (!co.IsActivated) { co.SetActive(true); } this.SetSprite(co, 9); } #if UNITY_EDITOR this.editorTestValue = this.value; #endif// UNITY_EDITOR this.Rebuild(); return; } if (this.ElementsCount > this.ValueCount) { if (0 != this.fillZero) { if (this.fillZero > this.ValueCount) { this.ZeroCount = this.fillZero - this.ValueCount; } else { this.ZeroCount = 0; } } } for (int digit = this.Count; digit < this.ElementsCount; ++digit) { this.Elements[digit].SetActive(false); } // fill to number uint remainValue = this.value; for (int digit = 0, digitMax = this.ValueCount; digit < digitMax; ++digit) { uint numberIdx = remainValue % 10; remainValue /= 10; UICache co = this.Elements[digit]; if (!co.IsActivated) { co.SetActive(true); } this.SetSprite(co, numberIdx); } // fill to 0000... for (int digit = this.ValueCount, digitMax = digit + this.ZeroCount; digit < digitMax; ++digit) { UICache co = this.Elements[digit]; if (!co.IsActivated) { co.SetActive(true); } this.SetSprite(co, 0); } this.Rebuild(); }