/// <summary> /// 绘制一条内容 /// </summary> /// <param name="str">大标题内容</param> /// <param name="message">小标题内容</param> public static void DrawOneContent(FMDItem info) { if (_H1 == null) { Init(); } //绘制标题 if (info.IsImage) { DrawTex(info); return; } //绘制标题 if (!string.IsNullOrEmpty(info.H1)) { GUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(info.Url)) { if (GUILayout.Button(info.H1, _LinkH1, GUILayout.ExpandWidth(true))) { Application.OpenURL(info.Url); } } else { GUILayout.Label(info.H1, _H1, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); } else if (!string.IsNullOrEmpty(info.Url)) { EditorGUILayout.BeginVertical(new GUIStyle("Box")); if (GUILayout.Button(info.H2, _LinkH2)) { Application.OpenURL(info.Url); } EditorGUILayout.TextArea(info.Description, _Tx_Dec); EditorGUILayout.EndVertical(); } else { //绘制正常的 EditorGUILayout.BeginVertical(new GUIStyle("Box")); EditorGUILayout.TextArea(info.H2, _style01); EditorGUILayout.TextArea(info.Description, _Tx_Dec); EditorGUILayout.EndVertical(); } }
private static async void DrawTex(FMDItem info) { if (info.IsNotLoadUrl) { info.IsNotLoadUrl = false; if (!info.Url.Contains("http")) { string path = $"tex/{Path.GetFileName(info.Url)}"; Texture2D tex = ResLoadUnlit.GetAssetInPackageByRelative <Texture2D>(path); info.Texture = tex; } else { UnityWebRequest req = UnityWebRequestTexture.GetTexture(info.Url); req.SendWebRequest(); while (!req.isDone) { await Task.Delay(1000); } var tex = req.downloadHandler as DownloadHandlerTexture; if (tex != null) { info.Texture = tex.texture; } // await Task.Delay(2000); req.Dispose(); } } else if (info.Texture != null) { var width = 300 * (float)info.Texture.width / info.Texture.height; if (GUILayout.Button(info.Texture, _imgStyle, GUILayout.Width(width), GUILayout.Height(300))) { EditorTipWindow.Push(info.Texture); } } }