/// <summary> /// 绘制:选择要播放的蓝图 /// </summary> private void Draw_select() { GUILayout.Label("输入路径:"); mSelectPath = GUILayout.TextField(mSelectPath); if (GUILayout.Button("选择")) { var path = EditorUtility.OpenFilePanel("选择对话蓝图", System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Assets"), "asset"); var cur_path = System.IO.Directory.GetCurrentDirectory(); cur_path = cur_path.Replace("\\", "/"); cur_path = cur_path + "/"; path = path.Replace(cur_path, ""); //path = path.Replace("\\", "/"); mSelectPath = path; } GUILayout.Space(10); if (!mSelectPath.IsNullOrEmpty()) { if (GUILayout.Button("播放")) { AssetDatabase.Refresh(); AssetDatabase.ReleaseCachedFileHandles(); var asset = AssetDatabase.LoadAssetAtPath <DialogueBluePrint>(mSelectPath); if (asset == null) { EditorUtility.DisplayDialog("失败", "载入文件失败", "嗯"); return; } mPlayer.PlayDialogue(asset); } } }
private void Awake() { m_BtnBg.onClick.AddListener(() => { m_Player.Next(); }); m_ChooseRoot.gameObject.SetActive(false); m_Player = new DialoguePlayer(); m_Player.OnDoChoose = (choose) => { m_ChooseRoot.gameObject.SetActive(true); m_ChooseBtnRoot.transform.RemoveAllChild(); m_TxtTitle.text = choose.GetTitle(); m_TxtContent.text = choose.GetContent(); var chooses = choose.Chooses; for (int i = 0; i < chooses.Count; i++) { var choosePicked = chooses[i]; var go = Instantiate(m_BtnPrefab.gameObject, Vector3.zero, Quaternion.identity, m_ChooseBtnRoot.transform); var chooseBtn = go.GetComponent <DramaChooseBtn>(); chooseBtn.Txt.text = chooses[i].Title; chooseBtn.Btn.onClick.AddListener(() => { m_Player.PickChoose(choosePicked); m_ChooseBtnRoot.transform.RemoveAllChild(); m_ChooseRoot.gameObject.SetActive(false); }); } }; m_Player.OnDoContent = (content) => { m_TxtTitle.text = content.GetTitle(); m_TxtContent.text = content.GetContent(); }; m_Player.OnDoFinish = (finish) => { m_TxtTitle.text = ""; m_TxtContent.text = ""; gameObject.SetActive(false); }; m_Player.PlayDialogue(m_BluePrint); }