public void EditorCheckCachable() { if (!this.Cacheable) { this.caches = null; } }
protected override void OnEditorRebuild() { base.OnEditorRebuild(); if (!this.image) { this.image = this.GetComponent <Image>(); } if (!this.sprites) { this.sprites = this.GetComponent <SpritesComponent>(); } }
protected override void OnEditorSetting() { base.OnEditorSetting(); if (!this.target) { this.target = this.GetComponent <Graphic>(); } if (!this.sprites) { this.sprites = this.GetComponent <SpritesComponent>(); } if (null == this.sprites || 0 == this.sprites.Count) { this.currentIndex = 0; } }
public void EditorSetSprites(SpritesComponent sprs) { this.sprites = sprs; }
public void SetSprites(SpritesComponent sprites) { this.sprites = sprites; this.SetIndex(this.CurrentIndex); }
protected override void OnEditorSetting() { base.OnEditorSetting(); if (!this.sprites) { this.sprites = this.GetComponent <SpritesComponent>(); if (!this.sprites) { Debug.LogWarning("NUMBER_BOX_EDITWARN:SPRITES_COMPONENT_IS_NULL!:" + this.name); return; } } //int sprCount = this.sprites.Count; //if (0 != sprCount && 10 != sprCount) //{ // Debug.LogWarning("NUMBER_BOX_EDITWARN:MISMATCH_COUNT:SPR_COUNT:" + sprCount); // foreach (SpriteCache sc in this.sprites.Elements) // Debug.Log(sc); //} var alignBase = this.AlignBase; if (null != this.Elements && 0 < this.ElementsCount) { for (int n = this.ElementsCount - 1; -1 < n; --n) { var co = this.Elements[n]; if (!co) { this.Elements.RemoveAt(n); } } } else if (alignBase) { for (int n = 0; n < 999; ++n) { var transChild = alignBase.Find(n.ToString()); if (!transChild) { break; } if (null == this.Elements) { this.EditorResetElements(new List <UICache>()); } this.Elements.Add(new UICache(transChild.gameObject)); } } if (alignBase && 0 < this.editorGenElems) { int cnt = this.editorGenElems; this.editorGenElems = 0; if (null == this.Elements) { this.EditorResetElements(new List <UICache>(cnt)); } var copyModel = this.editorGenElemsObjCopyModel; if (!copyModel && 0 < this.ElementsCount && this.Elements[0]) { copyModel = this.Elements[0].Graphic; } for (int n = 0; n < cnt; ++n) { int idx = this.ElementsCount; string name = idx.ToString(); if (copyModel) { var copyTrans = copyModel.rectTransform; if (copyModel is Image) { var component = UIExtension.CreateUIObject <Image>(name, alignBase, Vector3.zero, copyTrans.sizeDelta, copyTrans.localScale, copyTrans.localRotation); component.sprite = ((Image)copyModel).sprite; var co = this.CreateElement(component.rectTransform, idx); if (co) { this.Elements.Add(co); } continue; } else if (copyModel is RawImage) { var component = UIExtension.CreateUIObject <RawImage>(name, alignBase, Vector3.zero, copyTrans.sizeDelta, copyTrans.localScale, copyTrans.localRotation); component.texture = ((RawImage)copyModel).texture; var co = this.CreateElement(component.rectTransform, idx); if (co) { this.Elements.Add(co); } continue; } } // NOTE: 없다. 걍 대충 때려 박는다. var componentDef = UIExtension.CreateUIObject <Image>(this.ElementsCount.ToString(), alignBase, Vector3.zero, new Vector2(20, 20)); var coDef = this.CreateElement(componentDef.rectTransform, idx); if (coDef) { this.Elements.Add(coDef); } } this.Elements.Sort(this.SetupSort); } if (this.UseComma) { for (int n = 0, cnt = this.CommaCapacity; n < cnt; ++n) { var comma = this.GetComma(n); if (comma) { comma.Rebuild(); } } } if (null != this.signs) { for (int n = 0, cnt = this.SignCapacity; n < cnt; ++n) { var sign = this.GetSign(n); if (sign) { sign.Rebuild(); } } } this.SetupPositions(); }
protected override void OnEditorSetting() { base.OnEditorSetting(); if (!this.sprites) { this.sprites = this.GetComponent <SpritesComponent>(); if (!this.sprites) { Debug.LogWarning("IMAGE_TEXT_BOX_EDITWARN:SPRITES_COMPONENT_IS_NULL!:" + this.name); return; } } int sprCount = this.sprites.Count; int idxCount = this.indexes.Length; if (sprCount != idxCount) { Debug.LogWarning("IMAGE_TEXT_BOX_EDITWARN:MISMATCH_COUNT:SPR_COUNT:" + sprCount + ", IDX_COUNT:" + idxCount); foreach (SpriteCache sc in this.sprites.Elements) { Debug.Log(sc); } } if (null != this.Elements) { for (int n = this.ElementsCount - 1; -1 < n; --n) { var co = this.Elements[n]; if (!co) { this.Elements.RemoveAt(n); } } } var alignBase = this.AlignBase; if (alignBase && 0 < this.editorGenElems) { int cnt = this.editorGenElems; this.editorGenElems = 0; if (null == this.Elements) { this.EditorResetElements(new List <UICache>(cnt)); } var copyModel = this.editorGenElemsCopyModel; if (!copyModel && 0 < this.ElementsCount && this.Elements[0]) { copyModel = this.Elements[0].Graphic; } for (int n = 0; n < cnt; ++n) { int idx = this.ElementsCount; string name = idx.ToString(); if (copyModel) { var copyTrans = copyModel.rectTransform; if (copyModel is Image) { var component = UIExtension.CreateUIObject <Image>(name, alignBase, Vector3.zero, copyTrans.sizeDelta, copyTrans.localScale, copyTrans.localRotation); component.sprite = ((Image)copyModel).sprite; var co = this.CreateElement(component.rectTransform, idx); if (co) { this.Elements.Add(co); } continue; } else if (copyModel is RawImage) { var component = UIExtension.CreateUIObject <RawImage>(name, alignBase, Vector3.zero, copyTrans.sizeDelta, copyTrans.localScale, copyTrans.localRotation); component.texture = ((RawImage)copyModel).texture; var co = this.CreateElement(component.rectTransform, idx); if (co) { this.Elements.Add(co); } continue; } } // NOTE: 없다. 걍 대충 때려 박는다. var componentDef = UIExtension.CreateUIObject <Image>(this.ElementsCount.ToString(), alignBase, Vector3.zero, new Vector2(20, 20)); var coDef = this.CreateElement(componentDef.rectTransform, idx); if (coDef) { this.Elements.Add(coDef); } } this.Elements.Sort(this.SetupSort); } this.SetupPositions(); this.SetText(this.editorTestString); if (-1 != this.editorTestAddCharIndex) { var ret = this.AddChar(this.editorTestAddCharValue, this.editorTestAddCharIndex); Debug.Log("ADD:" + ret); } if (-1 != this.editorTestRemoveCharIndex) { var ret = this.RemoveChar(this.editorTestRemoveCharIndex); Debug.Log("REMOVE:" + ret); } }