/// <summary> /// Update the target pixel coordinates of the sprites. /// </summary> public void UpdateTargetPixelCoordinates() { SpriteAndPixelCoordinatesPairs.Clear(); int?_pixelCount = null; foreach (Sprite _sprite in Sprites) { SpriteAndPixelCoordinatesPair _spriteAndPixelCoordinatesPair = new SpriteAndPixelCoordinatesPair() { Sprite = _sprite, }; List <Vector2> _pixelCoordinates = GetPixelCoordinates(_sprite); _spriteAndPixelCoordinatesPair.PixelCoordinates = _pixelCoordinates; if (_pixelCount == null) { _pixelCount = _pixelCoordinates.Count; SpriteAndPixelCoordinatesPairs.Add(_spriteAndPixelCoordinatesPair); } else if (_pixelCount == _pixelCoordinates.Count) { SpriteAndPixelCoordinatesPairs.Add(_spriteAndPixelCoordinatesPair); } else { Debug.LogError("Sprite " + _sprite.name + " with label " + Label + " does not have the same amount of pixels as the other sprites, has " + _pixelCoordinates.Count + " needs " + _pixelCount + ", color between " + MinColor + " and " + MaxColor); break; } } }
/// <summary> /// Get the target pixel coordinates of a sprite. /// </summary> /// <param name="_sprite"></param> /// <returns></returns> public List <Vector2> GetTargetPixelCoordinates(Sprite _sprite) { SpriteAndPixelCoordinatesPair _spriteAndPixelCoordinatesPair = SpriteAndPixelCoordinatesPairs.Find(x => x.Sprite == _sprite); if (_spriteAndPixelCoordinatesPair == null) { Debug.LogError("SpriteAndPixelCoordinatesPair with sprite " + _sprite.name + " and label " + Label + " does not exist"); return(null); } return(_spriteAndPixelCoordinatesPair.PixelCoordinates); }