public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int position) { // Do not allow editing palettes if (brushTarget.layer == 31) { return; } Erase(grid, brushTarget, position); int index = Mathf.Clamp(Mathf.FloorToInt(GetPerlinValue(position, m_PerlinScale, k_PerlinOffset) * m_Prefabs.Length), 0, m_Prefabs.Length - 1); GameObject prefab = m_Prefabs[index]; GameObject instance = (GameObject)PrefabUtility.InstantiatePrefab(prefab); ItemObject itemObject = instance.GetComponentInChildren <ItemObject>(); itemObject.ItemType = m_ItemType; itemObject.AddToCurrentAmount(m_ItemType, m_Amount); // TextMesh textMesh = instance.GetComponentInChildren<TextMesh>(); // textMesh.text = m_amount.ToString(); Undo.RegisterCreatedObjectUndo((Object)instance, "Paint Prefabs"); if (instance != null) { instance.transform.SetParent(brushTarget.transform); instance.transform.position = grid.LocalToWorld(grid.CellToLocalInterpolated(new Vector3Int(position.x, position.y, m_Z) + new Vector3(.5f, .5f, .5f))); } }