// 从SpriteSleeperManager中找到本Image,所在的atlas // 记录其tag // 并标记引用此tag private void FindTag() { if (string.IsNullOrEmpty(Tag) && _image != null && _manager != null && !_manager.Equals(null)) { // 获取Image控件的Sprite Sprite sprite = _image.sprite; if (sprite != null) { // 保存自己的sprite名称 SpriteName = sprite.name; // sprite对应的texture Texture2D texture = sprite.texture; if (texture != null) { // 从SpriteSleeperManager中,获取texture对应的tag string tag = _manager.GetTag(texture); if (tag != null) { StopListeningForAtlases(); Tag = tag; // _manager.RefTag(Tag); } } } } }
private void FindTag() { if (string.IsNullOrEmpty(Tag) && _image != null && _manager != null && !_manager.Equals(null)) { Sprite sprite = _image.sprite; if (sprite != null) { SpriteName = sprite.name; Texture2D texture = sprite.texture; if (texture != null) { string tag = _manager.GetTag(texture); if (tag != null) { StopListeningForAtlases(); Tag = tag; _manager.RefTag(Tag); } } } } }