From d97fdf7864181a7802c08c409a6421c3e81ecf60 Mon Sep 17 00:00:00 2001 From: liyuehai Date: Fri, 7 Jun 2019 18:00:18 +0800 Subject: [PATCH] fix auto generate icon's error & platform protect --- Assets/Stickers/Editor/AssetCatalog.cs | 2 ++ Assets/Stickers/Editor/PBX/Objects.cs | 3 +++ Assets/Stickers/Editor/PBX/Sections.cs | 2 ++ Assets/Stickers/Editor/PBX/Serializer.cs | 2 ++ Assets/Stickers/Editor/PBX/Utils.cs | 2 ++ Assets/Stickers/Editor/PBXProject.cs | 2 ++ Assets/Stickers/Editor/PBXProjectData.cs | 2 ++ Assets/Stickers/Editor/StickerPackEditor.cs | 2 +- Assets/Stickers/Editor/StickerTest.cs | 6 ++++-- Assets/Stickers/Editor/StickersBuildPostProcess.cs | 6 ++++-- Assets/Stickers/Editor/StickersExport.cs | 6 ++++-- Assets/Stickers/StickerPackIcon.cs | 2 +- Assets/Stickers/TextureScale.cs | 2 +- 13 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Assets/Stickers/Editor/AssetCatalog.cs b/Assets/Stickers/Editor/AssetCatalog.cs index a15247c..5a1daa2 100644 --- a/Assets/Stickers/Editor/AssetCatalog.cs +++ b/Assets/Stickers/Editor/AssetCatalog.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System; using System.Collections.Generic; using System.IO; @@ -706,3 +707,4 @@ public override void Write() } } // namespace UnityEditor.iOS.Xcode +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/PBX/Objects.cs b/Assets/Stickers/Editor/PBX/Objects.cs index fc55bd5..ff26f8f 100644 --- a/Assets/Stickers/Editor/PBX/Objects.cs +++ b/Assets/Stickers/Editor/PBX/Objects.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System.Collections.Generic; using System.Collections; using System.Text.RegularExpressions; @@ -891,3 +892,5 @@ public override void UpdateVars() } } // namespace UnityEditor.iOS.Xcode + +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/PBX/Sections.cs b/Assets/Stickers/Editor/PBX/Sections.cs index dc029d6..a4c90f6 100644 --- a/Assets/Stickers/Editor/PBX/Sections.cs +++ b/Assets/Stickers/Editor/PBX/Sections.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System; using System.Collections; using System.Collections.Generic; @@ -119,3 +120,4 @@ public PBXProjectObjectData project } } // UnityEditor.iOS.Xcode +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/PBX/Serializer.cs b/Assets/Stickers/Editor/PBX/Serializer.cs index 2328117..af79456 100644 --- a/Assets/Stickers/Editor/PBX/Serializer.cs +++ b/Assets/Stickers/Editor/PBX/Serializer.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System; using System.Collections.Generic; using System.Text; @@ -256,3 +257,4 @@ public static void WriteArray(StringBuilder sb, PBXElementArray el, int indent, } } // namespace UnityEditor.iOS.Xcode +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/PBX/Utils.cs b/Assets/Stickers/Editor/PBX/Utils.cs index 48f4cde..0b7de0c 100644 --- a/Assets/Stickers/Editor/PBX/Utils.cs +++ b/Assets/Stickers/Editor/PBX/Utils.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System; using System.Collections.Generic; using System.Text; @@ -352,3 +353,4 @@ public static string[] SplitPath(string path) } } // UnityEditor.iOS.Xcode +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/PBXProject.cs b/Assets/Stickers/Editor/PBXProject.cs index 0b96e3c..2657967 100644 --- a/Assets/Stickers/Editor/PBXProject.cs +++ b/Assets/Stickers/Editor/PBXProject.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; @@ -1361,3 +1362,4 @@ public static string FixSlashes(string s) } } // namespace UnityEditor.iOS.Xcode +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/PBXProjectData.cs b/Assets/Stickers/Editor/PBXProjectData.cs index 6bac5c7..3d1c5b2 100644 --- a/Assets/Stickers/Editor/PBXProjectData.cs +++ b/Assets/Stickers/Editor/PBXProjectData.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; @@ -683,3 +684,4 @@ bool RepairStructureImpl(Dictionary allGuids) } // namespace UnityEditor.iOS.Xcode +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/StickerPackEditor.cs b/Assets/Stickers/Editor/StickerPackEditor.cs index 448ff31..b3b2433 100644 --- a/Assets/Stickers/Editor/StickerPackEditor.cs +++ b/Assets/Stickers/Editor/StickerPackEditor.cs @@ -174,7 +174,7 @@ private void DrawElementBackgroundCallback(Rect rect, int index, bool selected, GUI.Box(Rect.MinMaxRect(rect.xMin + 1f, rect.yMin, rect.xMax - 3f, rect.yMax), string.Empty); - if (Event.current.type != EventType.Repaint) + if (Event.current.type != UnityEngine.EventType.Repaint) return; if (elementStyle == null) diff --git a/Assets/Stickers/Editor/StickerTest.cs b/Assets/Stickers/Editor/StickerTest.cs index ac9b92b..7e3d2e5 100644 --- a/Assets/Stickers/Editor/StickerTest.cs +++ b/Assets/Stickers/Editor/StickerTest.cs @@ -1,4 +1,5 @@ -using System.IO; +#if UNITY_IOS +using System.IO; using Agens; using UnityEngine; using UnityEditor; @@ -47,4 +48,5 @@ private static void AssertSequence(Sticker sticker, int i) Assert.LessOrEqual(StickerPackEditor.CalculateFileSize(sticker), 500000, "Sticker " + sticker.Name + " is larger than the allowed 500KB"); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/StickersBuildPostProcess.cs b/Assets/Stickers/Editor/StickersBuildPostProcess.cs index f93e58a..e4e6407 100644 --- a/Assets/Stickers/Editor/StickersBuildPostProcess.cs +++ b/Assets/Stickers/Editor/StickersBuildPostProcess.cs @@ -1,4 +1,5 @@ -using UnityEditor; +#if UNITY_IOS +using UnityEditor; using UnityEditor.Callbacks; namespace Agens.Stickers @@ -16,4 +17,5 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj StickersExport.WriteToProject(pathToBuiltProject); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Stickers/Editor/StickersExport.cs b/Assets/Stickers/Editor/StickersExport.cs index facaac7..5df2a83 100644 --- a/Assets/Stickers/Editor/StickersExport.cs +++ b/Assets/Stickers/Editor/StickersExport.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_IOS +using System; using UnityEngine; using System.IO; using System.Linq; @@ -372,4 +373,5 @@ private static PlistDocument CreatePList(string name, string versionString = "1. return list; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/Stickers/StickerPackIcon.cs b/Assets/Stickers/StickerPackIcon.cs index d72d67c..e05f1e0 100644 --- a/Assets/Stickers/StickerPackIcon.cs +++ b/Assets/Stickers/StickerPackIcon.cs @@ -552,7 +552,7 @@ public Texture2D GetDefaultTexture(int width, int height) return null; } - var scaled = TextureScale.ScaledResized(appStore, width, height, Settings.BackgroundColor, Settings.FillPercentage / 100f, Settings.FilterMode, Settings.ScaleMode); + var scaled = TextureScale.ScaledResized(width == height ? appStore : messagesAppStore, width, height, Settings.BackgroundColor, Settings.FillPercentage / 100f, Settings.FilterMode, Settings.ScaleMode); if (scaled != null) { scaled.name = width + "x" + height; diff --git a/Assets/Stickers/TextureScale.cs b/Assets/Stickers/TextureScale.cs index a7db0e3..faea110 100644 --- a/Assets/Stickers/TextureScale.cs +++ b/Assets/Stickers/TextureScale.cs @@ -15,7 +15,7 @@ public static Texture2D ScaledResized(Texture2D src, int width, int height, Colo } var rtt = CreateScaledTexture(src,width,height,backgroundColor,fillPercentage,mode, anchor); - + RenderTexture.active = rtt; var texR = new Rect(0,0,width,height); result.ReadPixels(texR,0,0,true); result.Apply(false);