using DG.Tweening; using System; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.UI; /// /// UI接口 /// interface InterfaceUI { void show(Image mainBody, Image BG, Action ac = null); void hide(Image mainBody, Image BG, Action ac = null); public void hide(); public void show(); public void show(string str,string colorr = "", Action ac = null); } public class UIController : MonoBehaviour, InterfaceUI { public int id; public virtual void hide(Image mainBody, Image BG, Action ac = null) { //Sequence sequence = DOTween.Sequence(); //sequence.Append(mainBody.transform.DOScale(new Vector3(1.2f, 1.2f, 1.2f), 0.3f)); //sequence.Append(mainBody.transform.DOScale(new Vector3(0,0,0), 0.2f).SetDelay(0.1f)); //sequence.InsertCallback(0.4f, () => //{ // BG.color = new Color(0, 0, 0, 0); //}); //ac?.Invoke(); Destroy(BG.gameObject, 0.05f); } public virtual void show(Image mainBody, Image BG, Action ac = null) { BG.color = new Color32(0, 0, 0, 200); Sequence sequence = DOTween.Sequence(); sequence.Append(mainBody.transform.DOScale(new Vector3(1.1f, 1.1f, 1.1f), 0.2f)); sequence.Append(mainBody.transform.DOScale(new Vector3(1, 1, 1), 0.1f).SetDelay(0.025f)); ac?.Invoke(); } public virtual void hide() { } public virtual void show() { } public virtual void show(string str, string colorr = "", Action ac = null) { ac?.Invoke(); } /// /// 打开项目 /// public string OpenProject() { //OpenFileDlg pth = new OpenFileDlg(); //pth.structSize = Marshal.SizeOf(pth); //pth.filter = "All files (*.*)|*.*"; //pth.file = new string(new char[256]); //pth.maxFile = pth.file.Length; //pth.fileTitle = new string(new char[64]); //pth.maxFileTitle = pth.fileTitle.Length; //pth.initialDir = Application.dataPath.Replace("/", "\\") + "\\Resources"; //默认路径 //pth.title = "打开项目"; //pth.defExt = ""; //pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //if (OpenFileDialog.GetOpenFileName(pth)) //{ // string filepath = pth.file; //选择的文件路径; // Debug.Log(filepath); //} string selectedPath = FolderSelectDialog.OpenFolderDialog("选择文件夹"); if (!string.IsNullOrEmpty(selectedPath)) { Debug.Log("Selected Folder: " + selectedPath); } return selectedPath; } /// /// 保存文件项目 /// public void SaveProject() { //SaveFileDlg pth = new SaveFileDlg(); //pth.structSize = Marshal.SizeOf(pth); //pth.filter = "All files (*.*)|*.*"; //pth.file = new string(new char[256]); //pth.maxFile = pth.file.Length; //pth.fileTitle = new string(new char[64]); //pth.maxFileTitle = pth.fileTitle.Length; //pth.initialDir = Application.dataPath; //默认路径 //pth.title = "保存项目"; //pth.defExt = "dat"; //pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //if (SaveFileDialog.GetSaveFileName(pth)) //{ // string filepath = pth.file; //选择的文件路径; // Debug.Log(filepath); //} } }