IEnumerator alienSpawner() { deactivatingButtons(); spaceShipForScript = Instantiate(alienShip[shipType], alienShip[shipType].transform.localPosition, alienShip[shipType].transform.rotation); spaceShipForScript.transform.SetParent(GameObject.Find("Canvas").transform, false); //sound of coming musicManager.ObjectsSound(0); //this next line makes the button of prefab ship clickable, do not alter ! spaceShipForScript.GetComponentInChildren <Button>().onClick.AddListener(call: shipClicked); Vector3 destination = new Vector3(alienShip[shipType].transform.localPosition.x, -200f, 0f); do { spaceShipForScript.transform.localPosition = Vector3.Lerp(spaceShipForScript.transform.localPosition, destination, 4f * Time.deltaTime); yield return(new WaitForSeconds(0.02f)); } while ((int)spaceShipForScript.transform.localPosition.y > 0f); spaceShipForScript.transform.SetParent(maskHolder.transform, true); maskHolder.GetComponent <ScrollRect>().content = spaceShipForScript.GetComponent <RectTransform>(); activatingButtons(); musicManager.ObjectsSound(1); }
// Use this for initialization void Start() { PlayerPrefs.SetInt("netStock", 1); PlayerPrefs.SetInt("hayStackStock", 1); PlayerPrefs.SetInt("loveStock", 1); PlayerPrefs.GetString("Vibration", "True"); musicManager = GameObject.Find("Music Manager").GetComponent <music>(); musicManager.ObjectsSound(1); musicManager.UISFX(1); StartCoroutine(objectOpened(mainPanel)); }