Hi I’m making a old school 2D map editor for practice using Unity Editor GUI. I have the logic done it is slow. When selecting the tiles it slow and takes about a half - 2 seconds to update visually what you have selected. How would I speed this up. I could have each tile a button but that leads me to another problem. Some of my tiles are 16x16 like a treasure chest but some are a different size like 32X16 for parts of a wall or a fire pit. Having different tiles with different sizes would most likely be a pain to split.
void TileArea()
{
//278
//Tileset
EditorGUI.LabelField(new Rect(20, 170, 100, 20), "Tileset");
EditorGUI.TextField(new Rect(150, 168, position.width - 245, 20), "");
GUI.Button(new Rect(position.width - 90, 167, 70, 20), "Apply");
tilesetScrollPosition = GUI.BeginScrollView(new Rect(20, 195, position.width - 30, 500), tilesetScrollPosition, new Rect(0, 0, texture.width,texture.height));
//Background
GUI.color = new Color(0.2f, 0.2f, 0.2f);
GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height),pixelTexture);
GUI.color = Color.white;
//Tileset
GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture);
//Selection Rectangle
GUI.color = new Color(0.5f, 0.5f, 1f,0.8f);
GUI.DrawTexture(tilesetSelectionRect, pixelTexture);
GUI.color = Color.white;
if (Event.current.type == EventType.mouseDown)
{
tilesetSelectionRect = new Rect((int)(Event.current.mousePosition.x / 16) * 16, (int)(Event.current.mousePosition.y / 16) * 16,16,16);
mouseDown = true;
}
if (mouseDown)
tilesetSelectionRect = new Rect(tilesetSelectionRect.x, tilesetSelectionRect.y, (int)(Event.current.mousePosition.x / 16) * 16 - tilesetSelectionRect.x, (int)(Event.current.mousePosition.y / 16) * 16 - tilesetSelectionRect.y);
if (Event.current.type == EventType.MouseUp)
mouseDown = false;
GUI.EndScrollView();
}
