private void Start() { core = FindObjectOfType(typeof(KitCore)) as KitCore; piece = GetComponent <KitPiece>(); for (int i = 0; i < core.requiredPieces.Length; i++) { if (core.requiredPieces[i].piece.PieceName == piece.PieceName) { core.requiredPieces[i].Amount++; if (core.requiredPieces[i].Amount > core.requiredPieces[i].maxAmount) { core.RemovePiece(piece); } break; } } }
public void RemovePiece(KitPiece piece) { Destroy(piece.gameObject); pieces.Remove(piece); }