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(); }
static void OnCreateSampleObject() { Transform parent = UnityEditor.Selection.activeTransform; NumberBox.CreateSampleObject(parent); }
public void SetNumber(NumberBox value) { this.numb = value; }