private void SetIndex(int index) { ObjectInfo[] objectInfos = ObjectPresets[index].ObjectInfos; for (int i = 0; i < objectInfos.Length; i++) { // Object is UI element. TutorialPanel clone = Instantiate(PanePrefab, Vector3.zero, Quaternion.identity, gameObject.transform); RectTransform rect = objectInfos[i].Object.GetComponent <RectTransform>(); if (rect != null) { clone.GetComponent <RectTransform>().position = rect.position + objectInfos[i].Offset; // Object is regular game object. } else { clone.GetComponent <RectTransform>().position = Utility.ConvertToScreenPoint(objectInfos[i].Object.transform.position) + objectInfos[i].Offset; } clone.TextHeading.text = objectInfos[i].Heading; clone.TextDescription.text = objectInfos[i].Description; activeObjects.Add(clone.gameObject); } }
public void SpawnTutorial() { if (currentTutorialPanel != null) { currentTutorialPanel.MakeDisappear(); } if (currentArrow != null) { currentArrow.MakeDisappear(); } currentTutorialPanel = Instantiate(tutorialPanelPrefab).GetComponent <TutorialPanel>(); Tutorial current = tutorials[tutorialIndex]; currentTutorialPanel.Title.text = current.Title; currentTutorialPanel.Body.text = current.Body; if (current.Skip != "") { currentTutorialPanel.Skip.text = current.Skip; } RectTransform rectTransform = currentTutorialPanel.GetComponent <RectTransform>(); rectTransform.SetParent(UI.Instance.gameObject.GetComponent <RectTransform>()); rectTransform.localPosition = tutorialPanelPrefab.transform.localPosition;//Vector3.zero; if (current.ArrowPrefab != null) { currentArrow = Instantiate(current.ArrowPrefab).GetComponent <Arrow>(); RectTransform arrowRect = currentArrow.GetComponent <RectTransform>(); arrowRect.SetParent(UI.Instance.gameObject.GetComponent <RectTransform>()); arrowRect.localPosition = current.ArrowPoint; } else { currentArrow = null; } tutorialActions[tutorialIndex].Invoke(); }