update: 更新推送消息组件助手
parent
9d08938d77
commit
0ecf957902
|
|
@ -7,7 +7,7 @@ namespace Guru.Editor
|
|||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
public class PushIconHelper
|
||||
public class AndroidPushIconHelper
|
||||
{
|
||||
public static readonly int targetWidth = 96; // 目标宽度
|
||||
public static readonly int targetHeight = 96;
|
||||
|
|
@ -50,19 +50,28 @@ namespace Guru.Editor
|
|||
{
|
||||
MakeTextureReadable(source);
|
||||
|
||||
Texture2D result = new Texture2D(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);
|
||||
// Texture2D result = new Texture2D(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;
|
||||
|
||||
|
||||
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();
|
||||
return result;
|
||||
}
|
||||
|
|
@ -76,9 +76,12 @@ namespace Guru.Editor
|
|||
_isReady = false;
|
||||
if (File.Exists(docPath))
|
||||
{
|
||||
_docPath = 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.LoadXml(xmlStr);
|
||||
_docPath = docPath;
|
||||
if(!string.IsNullOrEmpty(docPath)) _docPath = docPath;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
|
@ -117,10 +120,10 @@ namespace Guru.Editor
|
|||
{
|
||||
if (_isReady)
|
||||
{
|
||||
if(string.IsNullOrEmpty(docPath)) docPath = _docPath;
|
||||
if (!string.IsNullOrEmpty(docPath))
|
||||
if (!string.IsNullOrEmpty(docPath)) _docPath = docPath;
|
||||
if (!string.IsNullOrEmpty(_docPath))
|
||||
{
|
||||
var dir = Directory.GetParent(docPath);
|
||||
var dir = Directory.GetParent(_docPath);
|
||||
if(!dir.Exists) dir.Create();
|
||||
_doc.Save(_docPath);
|
||||
|
||||
|
|
@ -228,6 +231,14 @@ namespace Guru.Editor
|
|||
item.SetAttribute(valueName, NamespaceAndroid, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetPermission(string key, string value, string valueName = "value", string keyName = "name")
|
||||
{
|
||||
_metadataList = _applicationNode?.SelectNodes("meta-data") ?? null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -395,10 +395,13 @@ namespace Guru.Editor
|
|||
GUI_OnConfigEnabled();
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_ANDROID
|
||||
GUILayout.Space(10);
|
||||
|
||||
// Push
|
||||
GUI_PushIconMaker();
|
||||
GUI_PushIconMaker();
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1017,9 +1020,8 @@ namespace Guru.Editor
|
|||
private void GUI_PushIconMaker()
|
||||
{
|
||||
float btnH = 24;
|
||||
|
||||
|
||||
_showSegmentPush = EditorGUILayout.Foldout(_showSegmentPush, "[ Push Icon ]");
|
||||
|
||||
_showSegmentPush = EditorGUILayout.Foldout(_showSegmentPush, "[ Android Push Icon ]");
|
||||
|
||||
// EditorGUILayout.LabelField("[ Push Icon ]", StyleItemTitle);
|
||||
|
||||
|
|
@ -1040,7 +1042,7 @@ namespace Guru.Editor
|
|||
{
|
||||
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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue