//BRUSH public void CreateBrush() { if (brush == null) { var oldBrush = map.transform.Find(TileBrush.brushGOName); while (oldBrush != null) { DestroyImmediate(oldBrush.gameObject); oldBrush = map.transform.Find(TileBrush.brushGOName); } brush = new GameObject(TileBrush.brushGOName).AddComponent <TileBrush>(); var comp = brush.gameObject.AddComponent <SpriteRenderer>(); brush.gameObject.transform.SetParent(map.transform); brush.gameObject.tag = TileBrush.brushGOTag; brush.size = map.tileSize; brush.ChangeBrush(map.prefabs[0]); map.brush = brush; comp.sortingLayerName = "Selected"; } }