public void ActivateRandomPrompt() { //update lists GetLocationLists(); //Transform _detach = _myList[Random.Range(0, _myList.Count)]; GameObject Prompt = prompts[Random.Range(0, prompts.Length)]; //freeplay means all locations are open if (promptsWaiting.Count < maxOpenPrompts) { PromptLocation randomLocation = openLocations[Random.Range(0, openLocations.Count)]; IsoObject iso = randomLocation.GetComponent <IsoObject>(); Vector2 promptLocation2D = isoWorld.IsoToScreen(iso.position); //Debug.Log("iso to screen: "+promptLocation2D); GameObject promptModal = Instantiate(Prompt); promptModal.transform.SetParent(canvas, false); promptModal.gameObject.GetComponent <Prompt>().promptLocation = randomLocation; //Debug.Log(promptModal.gameObject.GetComponent<Prompt>().promptLocation); promptModal.gameObject.GetComponent <RectTransform>().anchoredPosition = promptLocation2D; randomLocation.GetComponent <PromptLocation>().prompt = promptModal.GetComponent <Prompt>(); //promptModal.GetComponent<Prompt>().detailsText = randomScenario.details; } }
// Update is called once per frame void Update() { if (!timerEnd) { //decrease timer after showresults targetTime -= Time.deltaTime; } if (targetTime <= 0.0f) { timerEnd = true; targetTime = startTime; hideAll(); } Vector3 location3d = promptLocation.GetComponent <IsoObject>().position; Vector2 promptPosition = isoWorld.IsoToScreen(location3d); gameObject.GetComponent <RectTransform>().localPosition = new Vector2(promptPosition.x - 1920f, promptPosition.y - 1080f); //detailsText = (gameObject.transform.position.x + ", " + gameObject.transform.position.y); //detailsObject.GetComponent<Text>().text = detailsText; }