Chip TryPackageAndReplaceChip(string original) { ChipPackage oldPackage = Array.Find(GetComponentsInChildren <ChipPackage>(true), cp => cp.name == original); if (oldPackage != null) { Destroy(oldPackage.gameObject); } ChipPackage package = Instantiate(chipPackagePrefab, parent: transform); package.PackageCustomChip(activeChipEditor); package.gameObject.SetActive(false); Chip customChip = package.GetComponent <Chip> (); customChip.canBeEdited = true; int index = spawnableChips.FindIndex(c => c.chipName == original); if (index >= 0) { spawnableChips[index] = customChip; customChipUpdated?.Invoke(customChip); } return(customChip); }
Chip PackageChip() { ChipPackage package = Instantiate(chipPackagePrefab, parent: transform); package.PackageCustomChip(activeChipEditor); package.gameObject.SetActive(false); Chip customChip = package.GetComponent <Chip> (); customChipCreated?.Invoke(customChip); currentChipCreationIndex++; return(customChip); }