public void OnButtonClicked(LevelEditorSidebarButton button) { HidePanel(); if (currentButton) { currentButton.SetHighlight(false); } if (currentHeldObject) { Destroy(currentHeldObject.gameObject); } currentButton = button; currentButton.SetHighlight(true); if (currentTool == Tool.Create) { var worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); worldPos.z = 0; currentHeldObject = Instantiate(currentButton.createdObject); currentHeldObject.Init(this); currentHeldObject.transform.position = worldPos; currentHeldObject.GetComponentInChildren <SpriteRenderer>().color = Color.red; } }