ict.lixian.single/Assets/Scripts/UI/InterfaceUI/UIController.cs

106 lines
3.4 KiB
C#

using DG.Tweening;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// UI½Ó¿Ú
/// </summary>
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();
}
/// <summary>
/// ´ò¿ªÏîÄ¿
/// </summary>
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;
}
/// <summary>
/// ±£´æÎļþÏîÄ¿
/// </summary>
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);
//}
}
}