예제 #1
0
        /// <summary>
        /// Flood Fill Functionality
        ///Developed by Indie Studio
        ///https://www.assetstore.unity3d.com/en/#!/publisher/9268
        ///www.indiestd.com
        ///[email protected]
        /// </summary>
        /// <param name="texture2D">Texture2d reference.</param>
        /// <param name="clickPoint">Click point.</param>
        /// <param name="newColor">New color.</param>
        /// <param name="oldColor">Old color.</param>
        public void Fill(Texture2D texture2D, Vector2 clickPoint, Color32 newColor, Color32 oldColor)
        {
            if (oldColor.Equals(newColor))
            {
                brushApplyier.EnableDraggable();
                return;
            }

            /*
             * if (!CommonUtil.EqualsToOneOf(oldColor, allowedColors))
             * {
             *  return;
             * }
             */
            StartCoroutine(FillCoroutine(texture2D, clickPoint, newColor, oldColor));
        }
예제 #2
0
        /// <summary>
        /// apply color with sprite as a brush on target texture
        /// </summary>
        /// <param name="sprite"></param>
        /// <param name="offset"></param>
        /// <param name="applyanceColor"></param>
        /// <param name="brushApplyier"></param>
        public virtual void ApplyOn(Sprite sprite, Vector2 offset, Color applyanceColor, BrushApplyier brushApplyier, bool wentOutside)
        {
            if (brushApplyierMain == null)
            {
                brushApplyierMain = brushApplyier;
                strokeColor       = new Color(brushApplyierMain.ignoreColors[0].r, brushApplyierMain.ignoreColors[0].g, brushApplyierMain.ignoreColors[0].b, brushApplyierMain.ignoreColors[0].a);
            }
            if (wentOutside)
            {
                brushApplyierMain.pixelUVOld  = offset;
                brushApplyierMain.wentOutside = false;
            }

            if (Input.GetMouseButtonDown(0))
            {
                brushApplyierMain.pixelUVOld = offset;
                if (useCustomPatterns)
                {
                    DrawPatternCircle((int)offset.x, (int)offset.y);
                }
                else
                {
                    DrawCircle((int)offset.x, (int)offset.y, applyanceColor);
                }
                UpdateTexture();
            }

            //check distance from previous drawing point and connect them with DrawLine

            //if (Vector2.Distance(offset, brushApplyierMain.pixelUVOld) > brushSize)
            //{
            //if (!brushApplyierMain.pixelUVOld.Equals(offset))

            if (Mathf.Abs((int)offset.x - (int)brushApplyierMain.pixelUVOld.x) > 100 || Mathf.Abs((int)offset.y - (int)brushApplyierMain.pixelUVOld.y) > 100)
            {
                brushSizeDiv4 = idealAmount;
            }
            else
            {
                brushSizeDiv4 = minimumAmount;
            }

            if (useCustomPatterns)
            {
                DrawLineWithPattern(new Vector2((int)brushApplyierMain.pixelUVOld.x, (int)brushApplyierMain.pixelUVOld.y), new Vector2((int)offset.x, (int)offset.y));
            }
            else
            {
                DrawLine((int)brushApplyierMain.pixelUVOld.x, (int)brushApplyierMain.pixelUVOld.y, (int)offset.x, (int)offset.y, applyanceColor);
            }
            UpdateTexture();
            brushApplyier.EnableDraggable();
            brushApplyierMain.pixelUVOld = offset;



            //}
        }
예제 #3
0
        /// <summary>
        /// Apply brush on Raycast hit target
        /// </summary>
        /// <param name="sprite"></param>
        /// <param name="hit"></param>
        /// <param name="applyanceColor"></param>
        /// <param name="brushApplyier"></param>
        public override void ApplyOn(Sprite sprite, Vector2 offset, Color applyanceColor, BrushApplyier brushApplyier, bool wentOutside)
        {
            Color oldColor = sprite.texture.GetPixel((int)offset.x, (int)offset.y);

            brushApplyierMain = brushApplyier;

            if (brushApplyier.ignoreColors.Contains(oldColor))
            {
                brushApplyier.EnableDraggable();
                return;
            }

            FloodFillNew.instance.Fill2(sprite.texture, offset, applyanceColor, oldColor);
        }
예제 #4
0
 private void OnMouseExit()
 {
     brushApplyier.EnableDraggable();
 }