private void OnValidate() { // Always have at least one face available for pickup if (!allowPickupF && !allowPickupB && !allowPickupL && !allowPickupR) { allowPickupF = true; } stockAmount = Mathf.Clamp(stockAmount, 0, shelfSize); UpdatePickupPositionsArray(); _adjacentShelves.Clear(); _adjacentShelves.AddRange(GetAdjacentShelves()); // Update Stock ShelfVisual[] c = transform.GetComponentsInChildren <ShelfVisual>(); if (c.Length > 0) { UnityEditor.EditorApplication.delayCall += () => { for (int i = 0; i < c.Length; i++) { DestroyImmediate(c[i].gameObject); } }; } shelfVisual = null; shelfStockType = StockTypes.None; if (stock) { // Setup stats shelfStockType = stock.GetStockType(); GameObject newStockVisual = null; // Setup Visuals UnityEditor.EditorApplication.delayCall += () => { newStockVisual = Instantiate(stock.GetStockVisual(), transform, true); shelfVisual = newStockVisual.GetComponent <ShelfVisual>(); newStockVisual.transform.localPosition = Vector3.zero; }; } UpdateVisuals(); }