private void RenderDragAndDropPreview()
 {
     if (this.activeDragAndDrop && this.m_HoverData != null && this.m_HoverData.Count != 0)
     {
         RectInt minMaxRect = TileDragAndDrop.GetMinMaxRect(this.m_HoverData.Keys.ToList <Vector2Int>());
         minMaxRect.position   += base.mouseGridPosition;
         DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
         GridEditorUtility.DrawGridMarquee(this.grid, new BoundsInt(new Vector3Int(minMaxRect.xMin, minMaxRect.yMin, 0), new Vector3Int(minMaxRect.width, minMaxRect.height, 1)), Color.white);
     }
 }
Exemple #2
0
        public static Dictionary <Vector2Int, UnityEngine.Object> CreateHoverData(List <Texture2D> sheetTextures, List <Sprite> singleSprites, List <TileBase> tiles)
        {
            Dictionary <Vector2Int, UnityEngine.Object> dictionary = new Dictionary <Vector2Int, UnityEngine.Object>();
            Vector2Int vector2Int = new Vector2Int(0, 0);
            int        num        = 0;

            if (sheetTextures != null)
            {
                foreach (Texture2D current in sheetTextures)
                {
                    Dictionary <Vector2Int, UnityEngine.Object> dictionary2 = TileDragAndDrop.CreateHoverData(current);
                    foreach (KeyValuePair <Vector2Int, UnityEngine.Object> current2 in dictionary2)
                    {
                        dictionary.Add(current2.Key + vector2Int, current2.Value);
                    }
                    Vector2Int min = TileDragAndDrop.GetMinMaxRect(dictionary2.Keys.ToList <Vector2Int>()).min;
                    vector2Int += new Vector2Int(0, min.y - 1);
                }
            }
            if (vector2Int.x > 0)
            {
                vector2Int = new Vector2Int(0, vector2Int.y - 1);
            }
            if (singleSprites != null)
            {
                num = Mathf.FloorToInt(Mathf.Sqrt((float)singleSprites.Count));
                foreach (Sprite current3 in singleSprites)
                {
                    dictionary.Add(vector2Int, current3);
                    vector2Int += new Vector2Int(1, 0);
                    if (vector2Int.x > num)
                    {
                        vector2Int = new Vector2Int(0, vector2Int.y - 1);
                    }
                }
            }
            if (vector2Int.x > 0)
            {
                vector2Int = new Vector2Int(0, vector2Int.y - 1);
            }
            if (tiles != null)
            {
                num = Math.Max(Mathf.FloorToInt(Mathf.Sqrt((float)tiles.Count)), num);
                foreach (TileBase current4 in tiles)
                {
                    dictionary.Add(vector2Int, current4);
                    vector2Int += new Vector2Int(1, 0);
                    if (vector2Int.x > num)
                    {
                        vector2Int = new Vector2Int(0, vector2Int.y - 1);
                    }
                }
            }
            return(dictionary);
        }
        private void RenderDragAndDropPreview()
        {
            if (!activeDragAndDrop || m_HoverData == null || m_HoverData.Count == 0)
            {
                return;
            }

            RectInt rect = TileDragAndDrop.GetMinMaxRect(m_HoverData.Keys.ToList());

            rect.position         += mouseGridPosition;
            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
            GridEditorUtility.DrawGridMarquee(grid, new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, 0), new Vector3Int(rect.width, rect.height, 1)), Color.white);
        }