Skip to content

Commit 3d2c5c8

Browse files
author
Takashi Sakai
committed
release v0.3.0
2 parents d4f1c5a + 9a296e6 commit 3d2c5c8

File tree

7 files changed

+112
-37
lines changed

7 files changed

+112
-37
lines changed

Assets/DissolveEffectForUGUI/Demo/Dissolve.controller

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ AnimationClip:
3434
m_PreInfinity: 2
3535
m_PostInfinity: 2
3636
m_RotationOrder: 4
37-
attribute: m_Location
37+
attribute: m_DissolveFactor
3838
path: A
3939
classID: 114
4040
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -56,7 +56,7 @@ AnimationClip:
5656
m_PreInfinity: 2
5757
m_PostInfinity: 2
5858
m_RotationOrder: 4
59-
attribute: m_Location
59+
attribute: m_DissolveFactor
6060
path: B
6161
classID: 114
6262
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -78,7 +78,7 @@ AnimationClip:
7878
m_PreInfinity: 2
7979
m_PostInfinity: 2
8080
m_RotationOrder: 4
81-
attribute: m_Location
81+
attribute: m_DissolveFactor
8282
path: C
8383
classID: 114
8484
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -100,7 +100,7 @@ AnimationClip:
100100
m_PreInfinity: 2
101101
m_PostInfinity: 2
102102
m_RotationOrder: 4
103-
attribute: m_Location
103+
attribute: m_DissolveFactor
104104
path: D
105105
classID: 114
106106
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -176,7 +176,7 @@ AnimationClip:
176176
m_PreInfinity: 2
177177
m_PostInfinity: 2
178178
m_RotationOrder: 4
179-
attribute: m_Location
179+
attribute: m_DissolveFactor
180180
path: A
181181
classID: 114
182182
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -198,7 +198,7 @@ AnimationClip:
198198
m_PreInfinity: 2
199199
m_PostInfinity: 2
200200
m_RotationOrder: 4
201-
attribute: m_Location
201+
attribute: m_DissolveFactor
202202
path: B
203203
classID: 114
204204
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -220,7 +220,7 @@ AnimationClip:
220220
m_PreInfinity: 2
221221
m_PostInfinity: 2
222222
m_RotationOrder: 4
223-
attribute: m_Location
223+
attribute: m_DissolveFactor
224224
path: C
225225
classID: 114
226226
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}
@@ -242,7 +242,7 @@ AnimationClip:
242242
m_PreInfinity: 2
243243
m_PostInfinity: 2
244244
m_RotationOrder: 4
245-
attribute: m_Location
245+
attribute: m_DissolveFactor
246246
path: D
247247
classID: 114
248248
script: {fileID: 11500000, guid: 7f9a4349581d64dcabe67c494ee1d531, type: 3}

Assets/DissolveEffectForUGUI/UI-Effect-Dissolve.shader

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
33
Properties
44
{
55
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
6-
_Color ("Tint", Color) = (1,1,1,1)
7-
8-
_StencilComp ("Stencil Comparison", Float) = 8
9-
_Stencil ("Stencil ID", Float) = 0
10-
_StencilOp ("Stencil Operation", Float) = 0
11-
_StencilWriteMask ("Stencil Write Mask", Float) = 255
12-
_StencilReadMask ("Stencil Read Mask", Float) = 255
6+
[HideInInspector] _Color ("Tint", Color) = (1,1,1,1)
7+
8+
[HideInInspector] _StencilComp ("Stencil Comparison", Float) = 8
9+
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
10+
[HideInInspector] _StencilOp ("Stencil Operation", Float) = 0
11+
[HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255
12+
[HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255
1313

14-
_ColorMask ("Color Mask", Float) = 15
14+
[HideInInspector] _ColorMask ("Color Mask", Float) = 15
1515

16-
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
16+
[HideInInspector] [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
1717

18-
[Header(Dissolve)]
1918
_NoiseTex ("Noise Texture (A)", 2D) = "white" {}
2019
_EdgeWidth ("Edge width", Range (0.0001, 1)) = 0.05
20+
21+
[Header(Outer Setting)]
2122
_OuterEdgeColor ("Outer edge color", Color) = (1.0, 0.75, 0.0, 1.0)
2223
_OuterSoftness ("Outer softness", Range (0.0001, 1)) = 0.5
24+
25+
[Header(Inner Setting)]
2326
_InnerEdgeColor ("Inner edge color", Color) = (1.0, 0.0, 0.0, 1.0)
2427
_InnerSoftness ("Inner softness", Range (0.0001, 1)) = 0.5
2528
}

Assets/DissolveEffectForUGUI/UIDissolve.cs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class UIDissolve : BaseMeshEffect
3030
//################################
3131
// Serialize Members.
3232
//################################
33-
[SerializeField] [Range(0, 1)] float m_Location = 0;
33+
[SerializeField] [Range(0, 1)] float m_DissolveFactor = 0;
3434
[SerializeField] Material m_EffectMaterial;
3535

3636

@@ -45,7 +45,7 @@ public class UIDissolve : BaseMeshEffect
4545
/// <summary>
4646
/// Location for effect.
4747
/// </summary>
48-
public float location { get { return m_Location; } set { m_Location = Mathf.Clamp(value, 0, 1); _SetDirty(); } }
48+
public float dissolveFactor { get { return m_DissolveFactor; } set { m_DissolveFactor = Mathf.Clamp(value, 0, 1); _SetDirty(); } }
4949

5050
/// <summary>
5151
/// Effect material.
@@ -114,9 +114,14 @@ public static Material GetMaterial(string shaderName)
114114
/// </summary>
115115
public override void ModifyMesh(VertexHelper vh)
116116
{
117+
if (!IsActive() || dissolveFactor <= 0)
118+
return;
117119

118-
if (!IsActive())
120+
// Skip process.
121+
if (1 <= dissolveFactor) {
122+
vh.Clear ();
119123
return;
124+
}
120125

121126
// rect.
122127
Rect rect = graphic.rectTransform.rect;
@@ -129,7 +134,7 @@ public override void ModifyMesh(VertexHelper vh)
129134

130135
var x = Mathf.Clamp01 (vertex.position.x / rect.width + 0.5f);
131136
var y = Mathf.Clamp01 (vertex.position.y / rect.height + 0.5f);
132-
vertex.uv1 = new Vector2 (_PackToFloat (x, y, location), 0);
137+
vertex.uv1 = new Vector2 (_PackToFloat (x, y, dissolveFactor), 0);
133138

134139
vh.SetUIVertex(vertex, i);
135140
}
@@ -159,4 +164,38 @@ static float _PackToFloat(float x, float y, float z)
159164
+ Mathf.FloorToInt(x * PRECISION);
160165
}
161166
}
167+
168+
169+
[CanEditMultipleObjects, CustomEditor (typeof(UIDissolve))]
170+
public class UIDissolveEditor : Editor
171+
{
172+
private Editor materialEditor;
173+
private Material material;
174+
175+
void OnDisable()
176+
{
177+
if (materialEditor) {
178+
DestroyImmediate (materialEditor);
179+
}
180+
}
181+
182+
public override void OnInspectorGUI ()
183+
{
184+
base.OnInspectorGUI ();
185+
186+
var current = target as UIDissolve;
187+
if (current.effectMaterial) {
188+
if (material != current.effectMaterial) {
189+
material = current.effectMaterial;
190+
DestroyImmediate (materialEditor);
191+
}
192+
if (!materialEditor) {
193+
materialEditor = Editor.CreateEditor (current.effectMaterial);
194+
}
195+
materialEditor.DrawHeader ();
196+
materialEditor.OnInspectorGUI ();
197+
}
198+
199+
}
200+
}
162201
}

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [v0.3.0](https://github.com/mob-sakai/DissolveEffectForUGUI/tree/v0.3.0) (2018-04-24)
4+
5+
[Full Changelog](https://github.com/mob-sakai/DissolveEffectForUGUI/compare/v0.2.0...v0.3.0)
6+
7+
**Implemented enhancements:**
8+
9+
- Feature: Skip process when dissolve factor equal 1 [\#5](https://github.com/mob-sakai/DissolveEffectForUGUI/issues/5)
10+
- Feature: Skip process when dissolve factor equal 0 [\#4](https://github.com/mob-sakai/DissolveEffectForUGUI/issues/4)
11+
12+
## [v0.2.0](https://github.com/mob-sakai/DissolveEffectForUGUI/tree/v0.2.0) (2018-04-23)
13+
14+
[Full Changelog](https://github.com/mob-sakai/DissolveEffectForUGUI/compare/v0.1.0...v0.2.0)
15+
16+
**Implemented enhancements:**
17+
18+
- Feature: Show material editor in inspector [\#3](https://github.com/mob-sakai/DissolveEffectForUGUI/issues/3)
19+
320
## [v0.1.0](https://github.com/mob-sakai/DissolveEffectForUGUI/tree/v0.1.0) (2018-04-23)
421

522
[Full Changelog](https://github.com/mob-sakai/DissolveEffectForUGUI/compare/45db49cc27f879ae4ed460c55e50b592aaded503...v0.1.0)

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ DissolveEffectForUGUI
44
### NOTE: This project *will* be merged to [UIEffect](https://github.com/mob-sakai/UIEffect).
55

66
A dissolve effect for uGUI, without material instancing.
7-
![image](https://user-images.githubusercontent.com/12690315/39131615-dccdc2bc-474a-11e8-84b2-0513b64168a7.png)
7+
8+
![image](https://user-images.githubusercontent.com/12690315/39158165-6f8d68fc-4799-11e8-837f-4b74943d3f36.png)
89

910
[![](https://img.shields.io/github/release/mob-sakai/DissolveEffectForUGUI.svg?label=latest%20version)](https://github.com/mob-sakai/DissolveEffectForUGUI/release)
1011
[![](https://img.shields.io/github/release-date/mob-sakai/DissolveEffectForUGUI.svg)](https://github.com/mob-sakai/DissolveEffectForUGUI/releases)
@@ -22,19 +23,27 @@ A dissolve effect for uGUI, without material instancing.
2223
<br><br><br><br>
2324
## Description
2425

26+
![image](https://user-images.githubusercontent.com/12690315/39131615-dccdc2bc-474a-11e8-84b2-0513b64168a7.png)
27+
2528
DissolveEffectForUGUI applies _dissolve-effect_ to uGUI element (Image, RawImage, Text, etc...) **WITHOUT material instancing**.
2629
This will suppress extra draw calls and improve performance.
2730

28-
* Noise pattern image
29-
* Edge width
30-
* Outer/inner edge color
31-
* Outer/inner edge softness
31+
* Parameters
32+
* Dissolve factor
33+
* Noise pattern image (in material)
34+
* Edge width (in material)
35+
* Outer/inner edge color (in material)
36+
* Outer/inner edge softness (in material)
37+
38+
![image](https://user-images.githubusercontent.com/12690315/39143377-b9e632c0-4768-11e8-9d26-717304df41fb.png)
39+
3240

3341

3442
<br><br><br><br>
3543
## Demo
3644

37-
![demo](https://user-images.githubusercontent.com/12690315/39131616-dcf7ea60-474a-11e8-8e20-f9e5bd8b3f5c.gif)
45+
* ![demo](https://user-images.githubusercontent.com/12690315/39131616-dcf7ea60-474a-11e8-8e20-f9e5bd8b3f5c.gif)
46+
* Just 1 draw call!
3847

3948

4049

@@ -44,7 +53,7 @@ This will suppress extra draw calls and improve performance.
4453
1. Download DissolveEffectForUGUI.unitypackage from [Releases](https://github.com/mob-sakai/DissolveEffectForUGUI/releases).
4554
1. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
4655
1. Add `DissolveEffectForUGUI` component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector.
47-
1. Choose effect type and adjust values in inspector.
56+
1. Control effect parameters in inspector.
4857
1. Enjoy!
4958

5059

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "DissolveEffectForUGUI",
3-
"version": "0.1.0",
3+
"version": "0.3.0",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/mob-sakai/DissolveEffectForUGUI.git"
77
},
88
"src": "Assets/DissolveEffectForUGUI",
9+
"unity": "/Applications/Unity5.5.0p4/Unity5.5.0p4.app/Contents/MacOS/Unity",
910
"license": "MIT"
1011
}

release.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
#!/bin/bash -e
22

3+
# NOTE: Set an environment variable `CHANGELOG_GITHUB_TOKEN` by running the following command at the prompt, or by adding it to your shell profile (e.g., ~/.bash_profile or ~/.zshrc):
4+
# export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»"
5+
36
# Release the project with the following steps:
47
# 1. Update the release version in package.json.
58
# 2. Update "CHANGELOG.md" using "github_changelog_generator-1.15.0.pre.rc".
69
# 3. Commit package.json and CHANGELOG.md.
710
# 4. Merge into master branch.
811
# 5. Export unitypackage.
912
# 6. Release using "gh-release-3.2.0". (Upload unitypackage)
10-
UNITY_PATH=/Applications/Unity5.5.0p4/Unity5.5.0p4.app/Contents/MacOS/Unity
1113

1214

13-
# input version
15+
# input release version
1416
PACKAGE_NAME=`node -pe 'require("./package.json").name'`
1517
echo Github Release: $PACKAGE_NAME
1618
read -p "[? release version (for example: 1.0.0): " RELEASE_VERSION
1719
[ -z "$RELEASE_VERSION" ] && exit
1820

1921

20-
# update version
22+
# update version in package.json
2123
git checkout -B release develop
2224
sed -i -e "s/\"version\": \(.*\)/\"version\": \"${RELEASE_VERSION}\",/g" package.json
2325

@@ -36,6 +38,12 @@ read -p "[? continue? (y/N):" yn
3638
case "$yn" in [yY]*) ;; *) exit ;; esac
3739

3840

41+
# export unitypackage
42+
UNITY_EDITOR=`node -pe 'require("./package.json").unity'`
43+
PACKAGE_SRC=`node -pe 'require("./package.json").src'`
44+
"$UNITY_EDITOR" -quit -batchmode -projectPath "`pwd`" -exportpackage "$PACKAGE_SRC" "$PACKAGE_NAME.unitypackage"
45+
46+
3947
# commit files
4048
git add CHANGELOG.md -f
4149
git add package.json -f
@@ -49,10 +57,8 @@ git branch -D release
4957
git push origin master
5058

5159

52-
# export .unitypackage and release on Github
53-
PACKAGE_SRC=`node -pe 'require("./package.json").src'`
54-
$UNITY_PATH -quit -batchmode -projectPath "`pwd`" -exportpackage $PACKAGE_SRC $PACKAGE_NAME.unitypackage
55-
gh-release --draft --assets $PACKAGE_NAME.unitypackage
60+
# upload unitypackage and release on Github
61+
gh-release --draft --assets "$PACKAGE_NAME.unitypackage"
5662

5763

5864
echo "\n\n$PACKAGE_NAME v$RELEASE_VERSION has been successfully released!\n"

0 commit comments

Comments
 (0)