Skip to content

Commit f529ccd

Browse files
author
Takashi Sakai
authored
Merge pull request #43 from mob-sakai/develop
Release 2.0.0
2 parents 49fa49c + f9a7e31 commit f529ccd

462 files changed

Lines changed: 12046 additions & 14042 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Editor/ExportPackage.cs

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
using System.Linq;
33
using UnityEditor;
44
using UnityEngine;
5-
using BlurMode = UnityEngine.UI.UIEffect.BlurMode;
6-
using ColorMode = UnityEngine.UI.UIEffect.ColorMode;
7-
using ToneMode = UnityEngine.UI.UIEffect.ToneMode;
85
using UnityEngine.UI;
96

10-
namespace UnityEditor.UI
7+
namespace Coffee.UIExtensions
118
{
9+
using BlurMode = UIEffect.BlurMode;
10+
using ColorMode = UIEffect.ColorMode;
11+
using ToneMode = UIEffect.ToneMode;
12+
1213
public static class ExportPackage
1314
{
1415
const string kPackageName = "UIEffect.unitypackage";
@@ -24,47 +25,54 @@ static void Export()
2425
if (EditorApplication.isPlayingOrWillChangePlaymode)
2526
return;
2627

27-
// Export materials.
28-
AssetDatabase.StartAssetEditing();
29-
CreateMaterialVariant(
30-
Shader.Find(UIEffect.shaderName)
31-
, (ToneMode[])Enum.GetValues(typeof(ToneMode))
32-
, (ColorMode[])Enum.GetValues(typeof(ColorMode))
33-
, (BlurMode[])Enum.GetValues(typeof(BlurMode))
34-
);
35-
36-
CreateMaterialVariant(
37-
Shader.Find(UIEffectCapturedImage.shaderName)
38-
, new []{ ToneMode.None, ToneMode.Grayscale, ToneMode.Sepia, ToneMode.Nega, ToneMode.Pixel, ToneMode.Hue, }
39-
, (ColorMode[])Enum.GetValues(typeof(ColorMode))
40-
, (BlurMode[])Enum.GetValues(typeof(BlurMode))
41-
);
42-
AssetDatabase.StopAssetEditing();
43-
AssetDatabase.Refresh();
44-
4528
// Export package
4629
AssetDatabase.ExportPackage(kAssetPathes, kPackageName, ExportPackageOptions.Recurse | ExportPackageOptions.Default);
4730
UnityEngine.Debug.Log("Export successfully : " + kPackageName);
4831

32+
// Update readme.
4933
System.IO.File.Copy("Assets/UIEffect/Readme.md", "Readme.md", true);
5034
}
5135

52-
static void CreateMaterialVariant(Shader shader, ToneMode[] tones, ColorMode[] colors, BlurMode[] blurs)
36+
[MenuItem("Export Package/Generate Material Variants")]
37+
static void GenerateMaterialVariants()
5338
{
54-
var combinations = (from tone in tones
55-
from color in colors
56-
from blur in blurs
57-
select new { tone, color, blur }).ToArray();
39+
#if UIEFFECT_SEPARATE
40+
// On "UIEFFECT_SEPARATE" mode, generate effect materials on demand.
41+
return;
42+
#endif
43+
44+
// Export materials.
45+
AssetDatabase.StartAssetEditing();
46+
{
47+
// For UIEffect
48+
GenerateMaterialVariants(Shader.Find(UIEffect.shaderName));
49+
50+
// For UIEffectCapturedImage
51+
GenerateMaterialVariants(Shader.Find(UIEffectCapturedImage.shaderName));
52+
}
53+
AssetDatabase.StopAssetEditing();
54+
AssetDatabase.SaveAssets();
55+
AssetDatabase.Refresh();
56+
}
57+
58+
/// <summary>
59+
/// Generates the material variants.
60+
/// </summary>
61+
static void GenerateMaterialVariants(Shader shader)
62+
{
63+
var combinations = (from tone in (ToneMode[])Enum.GetValues(typeof(ToneMode))
64+
from color in (ColorMode[])Enum.GetValues(typeof(ColorMode))
65+
from blur in (BlurMode[])Enum.GetValues(typeof(BlurMode))
66+
select new { tone, color, blur }).ToArray();
5867

5968
for (int i = 0; i < combinations.Length; i++)
6069
{
6170
var comb = combinations[i];
6271

63-
if (comb.tone == 0 && comb.color == 0 && comb.blur == 0)
64-
continue;
65-
66-
UIEffectEditor.GetOrCreateMaterial(shader, comb.tone, comb.color, comb.blur);
72+
EditorUtility.DisplayProgressBar("Genarate Effect Material", UIEffect.GetVariantName(shader, comb.tone, comb.color, comb.blur), (float)i / combinations.Length);
73+
UIEffect.GetOrGenerateMaterialVariant(shader, comb.tone, comb.color, comb.blur);
6774
}
75+
EditorUtility.ClearProgressBar();
6876
}
6977
}
7078
}

0 commit comments

Comments
 (0)