接动态地图,忘记密码,文件弹窗置顶

This commit is contained in:
Caiyanpeng committed 2021-04-27 14:58:49 +08:00
1 parent 2b275d6dc5
commit 1002b0433a
206 files changed
+13484 -2849

No files matched your search

+68 -13
View File
@@ -120,7 +120,30 @@ namespace Assets.Scripts
}));
}
/*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/
public static void showLoading(this GameObject game)
{
var parent = Utils.FindUpParent(game.transform);
var loading = parent.Find("Loading");
if (loading == null)
{
var newLoading = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/Common/Loading"));
newLoading.name = "Loading";
newLoading.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
newLoading.transform.parent = parent;
loading = newLoading.transform;
}
loading.GetComponent<LoadingPf>().Initial();
loading.gameObject.SetActive(true);
}
public static void hideLoading(this GameObject game)
{
var parent = Utils.FindUpParent(game.transform);
var loading = parent.Find("Loading");
if (loading != null)
{
loading.gameObject.SetActive(false);
}
}
/*删除父亲节点下的所有孩子*/
static public void DestroyChildren(this Transform t)
{
@@ -160,15 +183,6 @@ namespace Assets.Scripts
else
img.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
}
static IEnumerator DownloadImageToLocal(RawImage img, string MediaUrl)
{
UnityWebRequest request = UnityWebRequestTexture.GetTexture(MediaUrl);
yield return request.SendWebRequest();
if (request.isNetworkError || request.isHttpError)
Debug.Log(request.error);
else
img.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
}
static IEnumerator DownloadImageCallBack(RawImage img, string MediaUrl,Action<string> action)
{
@@ -193,8 +207,48 @@ namespace Assets.Scripts
return FindUpParent(zi.parent);
}
/*获取最顶层对象*/
/*Texture相关*/
public static void WriteTextureToPlayerPrefs(string tag, Texture2D tex)
{
// if texture is png otherwise you can use tex.EncodeToJPG().
byte[] texByte = tex.EncodeToPNG();
// convert byte array to base64 string
string base64Tex = System.Convert.ToBase64String(texByte);
// write string to playerpref
PlayerPrefs.SetString(tag, base64Tex);
PlayerPrefs.Save();
}
public static Texture2D ReadTextureFromPlayerPrefs(string tag)
{
// load string from playerpref
string base64Tex = PlayerPrefs.GetString(tag, null);
if (!string.IsNullOrEmpty(base64Tex))
{
// convert it to byte array
byte[] texByte = System.Convert.FromBase64String(base64Tex);
Texture2D tex = new Texture2D(2, 2);
//load texture from byte array
if (tex.LoadImage(texByte))
{
return tex;
}
}
return null;
}
/*Texture相关*/
public static byte[] StreamToBytes(Stream stream)
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
return bytes;
}
public static Color HexToColor(string hex)
{
@@ -261,8 +315,8 @@ namespace Assets.Scripts
ofn.defExt = "JPG";//显示文件的类型
//注意 一下项目不一定要全选 但是0x00000008项不要缺少
ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
//0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008 OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
if (Win32.GetOpenFileName(ofn))
{
@@ -270,7 +324,7 @@ namespace Assets.Scripts
}
}
/*打开文件*/
/**/
/*文本框/下拉框错误*/
public static void SetValidate(Dictionary<string, Selectable> dict, JArray errorList)
{
foreach (var error in errorList)
@@ -289,5 +343,6 @@ namespace Assets.Scripts
//formDict[error.Value<string>("Filed")].error.Value<string>("ErrMsg");
}
}
/*文本框/下拉框错误*/
}
}
+3 -2
View File
@@ -12,10 +12,11 @@ namespace Assets.Scripts
[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool GetOpenFileName([In, Out] OpenFileName ofn);
public static bool GetOpenFileName1([In, Out] OpenFileName ofn)
{
return GetOpenFileName(ofn);
}
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
}
@@ -24,7 +25,7 @@ namespace Assets.Scripts
public class OpenFileName
{
public int structSize = 0;
public IntPtr dlgOwner = IntPtr.Zero;
public IntPtr dlgOwner = Win32.GetForegroundWindow();
public IntPtr instance = IntPtr.Zero;
public String filter = null;
public String customFilter = null;