update: 更新推送消息组件助手

deeplink
胡宇飞 2024-03-30 22:54:54 +08:00
parent 9d08938d77
commit 0ecf957902
4 changed files with 48 additions and 26 deletions

View File

@ -7,7 +7,7 @@ namespace Guru.Editor
using UnityEngine; using UnityEngine;
using System.IO; using System.IO;
public class PushIconHelper public class AndroidPushIconHelper
{ {
public static readonly int targetWidth = 96; // 目标宽度 public static readonly int targetWidth = 96; // 目标宽度
public static readonly int targetHeight = 96; public static readonly int targetHeight = 96;
@ -50,19 +50,28 @@ namespace Guru.Editor
{ {
MakeTextureReadable(source); MakeTextureReadable(source);
Texture2D result = new Texture2D(newWidth, newHeight); // Texture2D result = new Texture2D(newWidth, newHeight);
Color[] newColors = new Color[newWidth * newHeight]; // Color[] newColors = new Color[newWidth * newHeight];
//
// for (int y = 0; y < newHeight; y++)
// {
// for (int x = 0; x < newWidth; x++)
// {
// // 应用一些缩放逻辑来获取新的颜色值
// newColors[x + y * newWidth] = source.GetPixelBilinear((float)x / newWidth * source.width, (float)y / newHeight * source.height);
// }
// }
//
// result.SetPixels(newColors);
// result.Apply();
// return result;
for (int y = 0; y < newHeight; y++)
{
for (int x = 0; x < newWidth; x++)
{
// 应用一些缩放逻辑来获取新的颜色值
newColors[x + y * newWidth] = source.GetPixelBilinear((float)x / newWidth * source.width, (float)y / newHeight * source.height);
}
}
result.SetPixels(newColors); RenderTexture rt=new RenderTexture(newWidth, newHeight,24);
RenderTexture.active = rt;
Graphics.Blit(source,rt);
Texture2D result=new Texture2D(newWidth,newHeight);
result.ReadPixels(new Rect(0,0,newWidth,newHeight),0,0);
result.Apply(); result.Apply();
return result; return result;
} }

View File

@ -76,9 +76,12 @@ namespace Guru.Editor
_isReady = false; _isReady = false;
if (File.Exists(docPath)) if (File.Exists(docPath))
{ {
_docPath = docPath;
var xmlStr = File.ReadAllText(docPath); var xmlStr = File.ReadAllText(docPath);
ReadFromXml(xmlStr); ReadFromXml(xmlStr, docPath);
}
else
{
Debug.LogError($"--- File not found: {docPath}");
} }
} }
@ -87,7 +90,7 @@ namespace Guru.Editor
{ {
_doc = new XmlDocument(); _doc = new XmlDocument();
_doc.LoadXml(xmlStr); _doc.LoadXml(xmlStr);
_docPath = docPath; if(!string.IsNullOrEmpty(docPath)) _docPath = docPath;
Init(); Init();
} }
@ -117,10 +120,10 @@ namespace Guru.Editor
{ {
if (_isReady) if (_isReady)
{ {
if(string.IsNullOrEmpty(docPath)) docPath = _docPath; if (!string.IsNullOrEmpty(docPath)) _docPath = docPath;
if (!string.IsNullOrEmpty(docPath)) if (!string.IsNullOrEmpty(_docPath))
{ {
var dir = Directory.GetParent(docPath); var dir = Directory.GetParent(_docPath);
if(!dir.Exists) dir.Create(); if(!dir.Exists) dir.Create();
_doc.Save(_docPath); _doc.Save(_docPath);
@ -229,6 +232,14 @@ namespace Guru.Editor
} }
public void SetPermission(string key, string value, string valueName = "value", string keyName = "name")
{
_metadataList = _applicationNode?.SelectNodes("meta-data") ?? null;
}
#endregion #endregion

View File

@ -395,10 +395,13 @@ namespace Guru.Editor
GUI_OnConfigEnabled(); GUI_OnConfigEnabled();
} }
GUILayout.Space(10);
#if UNITY_ANDROID
GUILayout.Space(10);
// Push // Push
GUI_PushIconMaker(); GUI_PushIconMaker();
#endif
} }
@ -1018,8 +1021,7 @@ namespace Guru.Editor
{ {
float btnH = 24; float btnH = 24;
_showSegmentPush = EditorGUILayout.Foldout(_showSegmentPush, "[ Android Push Icon ]");
_showSegmentPush = EditorGUILayout.Foldout(_showSegmentPush, "[ Push Icon ]");
// EditorGUILayout.LabelField("[ Push Icon ]", StyleItemTitle); // EditorGUILayout.LabelField("[ Push Icon ]", StyleItemTitle);
@ -1040,7 +1042,7 @@ namespace Guru.Editor
{ {
GUI_Button("CREATE PUSH ASSETS", () => GUI_Button("CREATE PUSH ASSETS", () =>
{ {
if (PushIconHelper.SetPushIconAssets(_pushIconTexture, _pushIconColor)) if (AndroidPushIconHelper.SetPushIconAssets(_pushIconTexture, _pushIconColor))
{ {
EditorUtility.DisplayDialog("Set Push Icon", "Push Icon assets created success!", "OK"); EditorUtility.DisplayDialog("Set Push Icon", "Push Icon assets created success!", "OK");
} }