#pragma warning restore CS0649 // Start is called before the first frame update void Start() { sceneDataList = SceneListLoader.LoadSceneList(); GameObject temp = map.interactables[0]; Component[] c = temp.GetComponentsInChildren(typeof(Image)); if (c != null && c.Length != 0) { for (int i = 0; i < c.Length; i++) { if (c[i].gameObject != temp) { ((Image)c[i]).enabled = false; } } } map.interactables.RemoveAt(0); for (int i = 0; i < sceneDataList.list.Count; i++) { map.interactables.Add(CreateButton(sceneDataList.list[i], new Vector3(0, -10 * (i + 1), 0)).gameObject); } map.interactables.Add(temp); InteractableList interactableList = ListSingleton.instance; interactableList.UpdateMap(map); // interactableList.ClearList(); // interactableList.FindInteractables(); // interactableList.Next(); EventSystem.current.SetSelectedGameObject(interactableList.focusedGo); DescriptionPlayer dp = interactableList.focusedGo.GetComponent(typeof(DescriptionPlayer)) as DescriptionPlayer; dp.OnDescriptorPress(null); viewControl.CheckGraphics(); }
// Ao iniciar o module é realizada uma busca de objetos interagíveis. // TODO Verificar a possibilidade de popular a lista de outros meios protected override void Start() { base.Start(); interactableList = ListSingleton.instance; // interactableList.ClearList(); //interactableList.FindInteractables(); if (!interactableList.isEmpty) { eventSystem.SetSelectedGameObject(interactableList.focusedGo); DescriptionPlayer dp = interactableList.focusedGo.GetComponent(typeof(DescriptionPlayer)) as DescriptionPlayer; dp.OnDescriptorPress(null); } }
#pragma warning restore CS0649 // Realiza a mudança do canvas, desativando o atual e desativando o novo. public void changeCanvas(GameObject newCanvas) { // Troca o canvas ativo currentCanvas.SetActive(false); newCanvas.SetActive(true); // Obtêm o novo objeto que tem o foco atualmente. GameObject g = ListSingleton.instance.focusedGo; // Define ele como selecionado (Preciso fazer isso aqui ou ele não fica "aceso" na tela.) Selectable s = g.GetComponent(typeof(Selectable)) as Selectable; s.Select(); // Toca a descrição o primeiro botão selecionado na nova tela. DescriptionPlayer dp = ListSingleton.instance.focusedGo.GetComponent(typeof(DescriptionPlayer)) as DescriptionPlayer; dp.OnDescriptorPress(null); }
public void PlayTutorial() { GameObject g = GameObject.Find("SoundHandler"); Component [] audioDescriptions = g.GetComponents(typeof(AudioSource)) as Component[]; if (audioDescriptions == null) { throw new NullReferenceException("O componente de reprodução de audio não foi encontrado no objeto " + gameObject.transform.parent + "."); } AudioSource a; for (int i = 0; i < audioDescriptions.Length; i++) { a = audioDescriptions[i] as AudioSource; if (a.panStereo < 0) { left = a; } else if (a.panStereo > 0) { right = a; } } DescriptionPlayer.playingTutorial = true; left.clip = tutorial; right.clip = tutorial; left.Play(); right.Play(); DescriptionPlayer dp = ListSingleton.instance.focusedGo.GetComponent(typeof(DescriptionPlayer)) as DescriptionPlayer; if (dp == null) { throw new NullReferenceException("A descrição de audio para " + ListSingleton.instance.focusedGo + " não foi atribuída."); } DescriptionPlayer.UpdateCurrentClip(dp.audioClip); // descriptionPlayer.PlayTutorial(Resources.Load<AudioClip>("Sound/AudioDescription/Tutorials/Ambiente")); PlayerPrefs.SetInt("playedAmbienteTutorial", 1); }
private Button CreateButton(SceneData sceneData, Vector3 position) { // TODO Se necessário aumentar o tamanho de content Button b = sceneButtonFactory.make(Vector3.zero, parent.transform); b.transform.localPosition = position; Text t = b.GetComponentInChildren(typeof(Text)) as Text; t.text = sceneData.sceneName; AudioClip ac = Resources.Load <AudioClip>(sceneData.clipPath); DescriptionPlayer d = b.GetComponent(typeof(DescriptionPlayer)) as DescriptionPlayer; d.SetVariables(ac); b.onClick.AddListener(() => { SceneChanger c = (SceneChanger)b.gameObject.AddComponent(typeof(SceneChanger)); c.LoadGame(sceneData.scenePath); }); Debug.Log(b); return(b); }