public void CreateScrapIcon(EnemyType enemyType, Vector3 enemyPos) { Vector3 pos = new Vector3(Random.Range(-scrapIconParent.rect.width / 2, scrapIconParent.rect.width / 2), Random.Range(-scrapIconParent.rect.height / 2, scrapIconParent.rect.height / 2), 0); GameObject scrap = Instantiate(scrapIconPrefab, enemyPos, Quaternion.identity, scrapIconParent.transform); ScrapButton scrapScript = scrap.GetComponent <ScrapButton>(); scrapScript.enemyType = enemyType; scrapScript.endTarget = scrapIconTarget; scrapScript.MoveToContainer(pos); }
private void InstantiateButtonForEachSubPrefab(ScrapType scraptype) { ButtonPanel.SetActive(true); for (int subTypeIndex = 0; subTypeIndex < _ressourceManagement.PossiblePrefabs[(int)scraptype].Length; subTypeIndex++) { GameObject button = Instantiate(UpgradeButtonPrefab, ButtonTransforms[subTypeIndex]); ScrapButton scrapButton = button.GetComponent <ScrapButton>(); button.GetComponentInChildren <Text>().text = GetSubScrapName(scraptype, subTypeIndex); scrapButton.ScrapType = scraptype; scrapButton.SubTypeIndex = subTypeIndex; _uibuttons.Add(button); if (!_playerInventory.SubTypeIsInInventory((int)scraptype, subTypeIndex)) { button.GetComponent <Button>().interactable = false; } } }