app.hypergames.hypersdk 1.8.19 → 1.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/HyperLoader.unity +3 -3
- package/Runtime/Internal/Managers/DataManager.cs +38 -2
- package/Runtime/Internal/Managers/GameManager.cs +34 -23
- package/Runtime/Internal/UI/Animation/SlideUp.cs +6 -1
- package/Runtime/Internal/UI/Components/RoundedRawImage.cs +146 -0
- package/Runtime/Internal/UI/Components/RoundedRawImage.cs.meta +11 -0
- package/Runtime/Internal/UI/Modals/GamePausedModal.cs +2 -0
- package/Runtime/Internal/UI/Modals/TutorialButton.cs +10 -0
- package/Runtime/Internal/UI/Modals/TutorialLoaderModal.cs +31 -4
- package/Runtime/Internal/UI/Modals/TutorialModal.cs +814 -47
- package/Runtime/Plugins/WebGL/HyperTutorialCachePlugin.jslib +35 -53
- package/Runtime/Resources/Materials/RoundedRawImage.mat +65 -0
- package/Runtime/Resources/Materials/RoundedRawImage.mat.meta +8 -0
- package/Runtime/Resources/Materials.meta +8 -0
- package/Runtime/Resources/RenderTextures/TutorialVideoTexture P.renderTexture +3 -3
- package/Runtime/Resources/Shaders/RoundedRawImage.shader +142 -0
- package/Runtime/Resources/Shaders/RoundedRawImage.shader.meta +10 -0
- package/Runtime/Resources/Shaders/RoundedStrip.shader +152 -0
- package/Runtime/Resources/Shaders/RoundedStrip.shader.meta +10 -0
- package/Runtime/Resources/Shaders.meta +8 -0
- package/Runtime/Resources/Sprites/Frames/Square.png +0 -0
- package/Runtime/Resources/Sprites/Frames/Square.png.meta +186 -0
- package/Runtime/Resources/Sprites/TutorialModal/Button_Back.png.meta +1 -1
- package/Runtime/Resources/Sprites/TutorialModal/Button_Next.png.meta +1 -1
- package/Runtime/Resources/Sprites/TutorialModal/Knob.png.meta +1 -1
- package/Runtime/Resources/Sprites/TutorialModal/Tutorial_Background_Portrait.png.meta +3 -3
- package/Runtime/Resources/UIPrefabs/GameOverModal_Battle.prefab +1 -1
- package/Runtime/Resources/UIPrefabs/GameOverModal_Practice.prefab +1 -1
- package/Runtime/Resources/UIPrefabs/GamePausedModal_Battle.prefab +1 -1
- package/Runtime/Resources/UIPrefabs/IndicatorCircle.prefab +2 -2
- package/Runtime/Resources/UIPrefabs/TutorialLandscapeModal.prefab +1614 -1184
- package/Runtime/Resources/UIPrefabs/TutorialLandscapeModal.prefab.meta +1 -1
- package/Runtime/Resources/UIPrefabs/TutorialPortraitModal.prefab +1409 -948
- package/Runtime/Shared/DTOs/TutorialData.cs +18 -1
- package/package.json +1 -1
|
@@ -22,20 +22,20 @@ mergeInto(LibraryManager.library, {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
const cards = records
|
|
26
|
+
.filter(r => r && r.fileUrl)
|
|
27
|
+
.map((record, index) => ({
|
|
28
|
+
type: String(record.mediaType || "").toUpperCase() === "VIDEO" ? "video" : "images",
|
|
29
|
+
url: record.fileUrl,
|
|
30
|
+
description: record.description || "",
|
|
31
|
+
position: Number.isFinite(Number(record.position)) ? Number(record.position) : index
|
|
32
|
+
}))
|
|
33
|
+
.sort((a, b) => a.position - b.position);
|
|
34
|
+
|
|
35
|
+
Module['CachedTutorialData'] = { cards };
|
|
36
|
+
|
|
37
|
+
const downloadPromises = cards.map(async (card) => {
|
|
38
|
+
const url = card.url;
|
|
39
39
|
const match = await cache.match(url);
|
|
40
40
|
if (!match) {
|
|
41
41
|
const response = await fetch(url);
|
|
@@ -67,52 +67,34 @@ mergeInto(LibraryManager.library, {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
caches.open("tutorial-cache").then(async (cache) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
? cached.videos
|
|
73
|
-
: cached.images;
|
|
74
|
-
|
|
75
|
-
if (resources.length === 0) {
|
|
70
|
+
const cards = Array.isArray(cached.cards) ? cached.cards : [];
|
|
71
|
+
if (cards.length === 0) {
|
|
76
72
|
SendMessage(gameObject, methodName, "");
|
|
77
73
|
return;
|
|
78
74
|
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const cachedResponse = await cache.match(videoUrl);
|
|
76
|
+
const resolvedCards = [];
|
|
77
|
+
for (const card of cards) {
|
|
78
|
+
const cachedResponse = await cache.match(card.url);
|
|
84
79
|
if (!cachedResponse) {
|
|
85
|
-
console.warn("Cached response not found for:",
|
|
86
|
-
|
|
87
|
-
return;
|
|
80
|
+
console.warn("Cached response not found for:", card.url);
|
|
81
|
+
continue;
|
|
88
82
|
}
|
|
89
83
|
const blob = await cachedResponse.blob();
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (cachedResponse) {
|
|
102
|
-
const blob = await cachedResponse.blob();
|
|
103
|
-
imageUrls.push(URL.createObjectURL(blob));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (imageUrls.length > 0) {
|
|
108
|
-
SendMessage(gameObject, methodName, JSON.stringify({
|
|
109
|
-
type: "images",
|
|
110
|
-
urls: imageUrls
|
|
111
|
-
}));
|
|
112
|
-
} else {
|
|
113
|
-
SendMessage(gameObject, methodName, "");
|
|
114
|
-
}
|
|
84
|
+
resolvedCards.push({
|
|
85
|
+
type: card.type,
|
|
86
|
+
url: URL.createObjectURL(blob),
|
|
87
|
+
description: card.description,
|
|
88
|
+
position: card.position
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (resolvedCards.length === 0) {
|
|
93
|
+
SendMessage(gameObject, methodName, "");
|
|
94
|
+
return;
|
|
115
95
|
}
|
|
96
|
+
|
|
97
|
+
SendMessage(gameObject, methodName, JSON.stringify({ cards: resolvedCards }));
|
|
116
98
|
});
|
|
117
99
|
}
|
|
118
|
-
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
%YAML 1.1
|
|
2
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
3
|
+
--- !u!21 &2100000
|
|
4
|
+
Material:
|
|
5
|
+
serializedVersion: 8
|
|
6
|
+
m_ObjectHideFlags: 0
|
|
7
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
8
|
+
m_PrefabInstance: {fileID: 0}
|
|
9
|
+
m_PrefabAsset: {fileID: 0}
|
|
10
|
+
m_Name: RoundedRawImage
|
|
11
|
+
m_Shader: {fileID: 4800000, guid: 1f6345dd3b604134b8b847076a3d6b8c, type: 3}
|
|
12
|
+
m_Parent: {fileID: 0}
|
|
13
|
+
m_ModifiedSerializedProperties: 0
|
|
14
|
+
m_ValidKeywords: []
|
|
15
|
+
m_InvalidKeywords:
|
|
16
|
+
- _USEINVERTEDRADIUS_ON
|
|
17
|
+
m_LightmapFlags: 4
|
|
18
|
+
m_EnableInstancingVariants: 0
|
|
19
|
+
m_DoubleSidedGI: 0
|
|
20
|
+
m_CustomRenderQueue: -1
|
|
21
|
+
stringTagMap: {}
|
|
22
|
+
disabledShaderPasses: []
|
|
23
|
+
m_LockedProperties:
|
|
24
|
+
m_SavedProperties:
|
|
25
|
+
serializedVersion: 3
|
|
26
|
+
m_TexEnvs:
|
|
27
|
+
- _MainTex:
|
|
28
|
+
m_Texture: {fileID: 0}
|
|
29
|
+
m_Scale: {x: 1, y: 1}
|
|
30
|
+
m_Offset: {x: 0, y: 0}
|
|
31
|
+
m_Ints: []
|
|
32
|
+
m_Floats:
|
|
33
|
+
- _ColorMask: 15
|
|
34
|
+
- _InvertedRadius: 0
|
|
35
|
+
- _Radius: 75
|
|
36
|
+
- _Softness: 1.75
|
|
37
|
+
- _Stencil: 0
|
|
38
|
+
- _StencilComp: 8
|
|
39
|
+
- _StencilOp: 0
|
|
40
|
+
- _StencilReadMask: 255
|
|
41
|
+
- _StencilWriteMask: 255
|
|
42
|
+
- _UseInvertedRadius: 1
|
|
43
|
+
- _UseUIAlphaClip: 0
|
|
44
|
+
m_Colors:
|
|
45
|
+
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
|
46
|
+
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
|
47
|
+
- _CornerRadii: {r: 75, g: 75, b: 0, a: 0}
|
|
48
|
+
- _InvertedCornerRadii: {r: 0, g: 0, b: 962.5, a: 1481.2}
|
|
49
|
+
- _Pivot: {r: 0.5, g: 0.556, b: 0, a: 0}
|
|
50
|
+
- _RectSize: {r: 2532, g: 1216, b: 0, a: 0}
|
|
51
|
+
m_BuildTextureStacks: []
|
|
52
|
+
m_AllowLocking: 1
|
|
53
|
+
--- !u!114 &4644396538228076653
|
|
54
|
+
MonoBehaviour:
|
|
55
|
+
m_ObjectHideFlags: 11
|
|
56
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
57
|
+
m_PrefabInstance: {fileID: 0}
|
|
58
|
+
m_PrefabAsset: {fileID: 0}
|
|
59
|
+
m_GameObject: {fileID: 0}
|
|
60
|
+
m_Enabled: 1
|
|
61
|
+
m_EditorHideFlags: 0
|
|
62
|
+
m_Script: {fileID: 11500000, guid: 2c55e9ca2f9b6f54abf913573af8e38f, type: 3}
|
|
63
|
+
m_Name:
|
|
64
|
+
m_EditorClassIdentifier:
|
|
65
|
+
version: 7
|
|
@@ -12,8 +12,8 @@ RenderTexture:
|
|
|
12
12
|
Hash: 00000000000000000000000000000000
|
|
13
13
|
m_IsAlphaChannelOptional: 0
|
|
14
14
|
serializedVersion: 6
|
|
15
|
-
m_Width:
|
|
16
|
-
m_Height:
|
|
15
|
+
m_Width: 724
|
|
16
|
+
m_Height: 1286
|
|
17
17
|
m_AntiAliasing: 1
|
|
18
18
|
m_MipCount: -1
|
|
19
19
|
m_DepthStencilFormat: 90
|
|
@@ -24,7 +24,7 @@ RenderTexture:
|
|
|
24
24
|
m_UseDynamicScale: 1
|
|
25
25
|
m_UseDynamicScaleExplicit: 0
|
|
26
26
|
m_BindMS: 0
|
|
27
|
-
m_EnableCompatibleFormat:
|
|
27
|
+
m_EnableCompatibleFormat: 0
|
|
28
28
|
m_EnableRandomWrite: 0
|
|
29
29
|
m_TextureSettings:
|
|
30
30
|
serializedVersion: 2
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Shader "Hyper/UI/Rounded Raw Image"
|
|
2
|
+
{
|
|
3
|
+
Properties
|
|
4
|
+
{
|
|
5
|
+
[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
|
|
6
|
+
_Color ("Tint", Color) = (1,1,1,1)
|
|
7
|
+
_Radius ("Radius", Float) = 24
|
|
8
|
+
_CornerRadii ("Corner Radii", Vector) = (24,24,24,24)
|
|
9
|
+
_Softness ("Softness", Float) = 1.5
|
|
10
|
+
_RectSize ("Rect Size", Vector) = (100,100,0,0)
|
|
11
|
+
_Pivot ("Pivot", Vector) = (0.5,0.5,0,0)
|
|
12
|
+
|
|
13
|
+
_StencilComp ("Stencil Comparison", Float) = 8
|
|
14
|
+
_Stencil ("Stencil ID", Float) = 0
|
|
15
|
+
_StencilOp ("Stencil Operation", Float) = 0
|
|
16
|
+
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
|
17
|
+
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
|
18
|
+
_ColorMask ("Color Mask", Float) = 15
|
|
19
|
+
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
SubShader
|
|
23
|
+
{
|
|
24
|
+
Tags
|
|
25
|
+
{
|
|
26
|
+
"Queue"="Transparent"
|
|
27
|
+
"IgnoreProjector"="True"
|
|
28
|
+
"RenderType"="Transparent"
|
|
29
|
+
"PreviewType"="Plane"
|
|
30
|
+
"CanUseSpriteAtlas"="True"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Stencil
|
|
34
|
+
{
|
|
35
|
+
Ref [_Stencil]
|
|
36
|
+
Comp [_StencilComp]
|
|
37
|
+
Pass [_StencilOp]
|
|
38
|
+
ReadMask [_StencilReadMask]
|
|
39
|
+
WriteMask [_StencilWriteMask]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Cull Off
|
|
43
|
+
Lighting Off
|
|
44
|
+
ZWrite Off
|
|
45
|
+
ZTest [unity_GUIZTestMode]
|
|
46
|
+
Blend SrcAlpha OneMinusSrcAlpha
|
|
47
|
+
ColorMask [_ColorMask]
|
|
48
|
+
|
|
49
|
+
Pass
|
|
50
|
+
{
|
|
51
|
+
Name "Default"
|
|
52
|
+
|
|
53
|
+
CGPROGRAM
|
|
54
|
+
#pragma vertex vert
|
|
55
|
+
#pragma fragment frag
|
|
56
|
+
#pragma target 2.0
|
|
57
|
+
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
|
58
|
+
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
|
59
|
+
|
|
60
|
+
#include "UnityCG.cginc"
|
|
61
|
+
#include "UnityUI.cginc"
|
|
62
|
+
|
|
63
|
+
struct appdata_t
|
|
64
|
+
{
|
|
65
|
+
float4 vertex : POSITION;
|
|
66
|
+
float4 color : COLOR;
|
|
67
|
+
float2 texcoord : TEXCOORD0;
|
|
68
|
+
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
struct v2f
|
|
72
|
+
{
|
|
73
|
+
float4 vertex : SV_POSITION;
|
|
74
|
+
fixed4 color : COLOR;
|
|
75
|
+
float2 texcoord : TEXCOORD0;
|
|
76
|
+
float4 worldPosition : TEXCOORD1;
|
|
77
|
+
float2 localPosition : TEXCOORD2;
|
|
78
|
+
UNITY_VERTEX_OUTPUT_STEREO
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
sampler2D _MainTex;
|
|
82
|
+
fixed4 _Color;
|
|
83
|
+
fixed4 _TextureSampleAdd;
|
|
84
|
+
float4 _ClipRect;
|
|
85
|
+
float4 _MainTex_ST;
|
|
86
|
+
float _Radius;
|
|
87
|
+
float4 _CornerRadii;
|
|
88
|
+
float _Softness;
|
|
89
|
+
float4 _RectSize;
|
|
90
|
+
float4 _Pivot;
|
|
91
|
+
|
|
92
|
+
v2f vert(appdata_t v)
|
|
93
|
+
{
|
|
94
|
+
v2f OUT;
|
|
95
|
+
UNITY_SETUP_INSTANCE_ID(v);
|
|
96
|
+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
|
97
|
+
OUT.worldPosition = v.vertex;
|
|
98
|
+
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
|
99
|
+
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
|
100
|
+
OUT.localPosition = v.vertex.xy;
|
|
101
|
+
OUT.color = v.color * _Color;
|
|
102
|
+
return OUT;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fixed4 frag(v2f IN) : SV_Target
|
|
106
|
+
{
|
|
107
|
+
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
|
108
|
+
|
|
109
|
+
float2 rectSize = max(_RectSize.xy, float2(1.0, 1.0));
|
|
110
|
+
float2 center = (0.5 - _Pivot.xy) * rectSize;
|
|
111
|
+
float2 localFromCenter = IN.localPosition - center;
|
|
112
|
+
float4 cornerRadii = _CornerRadii;
|
|
113
|
+
if (dot(cornerRadii, float4(1.0, 1.0, 1.0, 1.0)) <= 0.0)
|
|
114
|
+
{
|
|
115
|
+
cornerRadii = float4(_Radius, _Radius, _Radius, _Radius);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
float radius = localFromCenter.y >= 0.0
|
|
119
|
+
? (localFromCenter.x < 0.0 ? cornerRadii.x : cornerRadii.y)
|
|
120
|
+
: (localFromCenter.x < 0.0 ? cornerRadii.w : cornerRadii.z);
|
|
121
|
+
radius = min(radius, min(rectSize.x, rectSize.y) * 0.5);
|
|
122
|
+
float softness = max(_Softness, 0.001);
|
|
123
|
+
float2 halfSize = rectSize * 0.5;
|
|
124
|
+
|
|
125
|
+
float2 q = abs(localFromCenter) - halfSize + radius;
|
|
126
|
+
float outsideDistance = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
|
|
127
|
+
color.a *= 1.0 - smoothstep(-softness, softness, outsideDistance);
|
|
128
|
+
|
|
129
|
+
#ifdef UNITY_UI_CLIP_RECT
|
|
130
|
+
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
|
131
|
+
#endif
|
|
132
|
+
|
|
133
|
+
#ifdef UNITY_UI_ALPHACLIP
|
|
134
|
+
clip(color.a - 0.001);
|
|
135
|
+
#endif
|
|
136
|
+
|
|
137
|
+
return color;
|
|
138
|
+
}
|
|
139
|
+
ENDCG
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Shader "Hyper/UI/Rounded Strip"
|
|
2
|
+
{
|
|
3
|
+
Properties
|
|
4
|
+
{
|
|
5
|
+
[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
|
|
6
|
+
_Color ("Tint", Color) = (1,1,1,1)
|
|
7
|
+
_RectSize ("Rect Size", Vector) = (998,150,0,0)
|
|
8
|
+
_CornerRadii ("Inset Cut Radii TL TR BR BL", Vector) = (0,0,75,75)
|
|
9
|
+
_Softness ("Softness", Float) = 1.5
|
|
10
|
+
|
|
11
|
+
_StencilComp ("Stencil Comparison", Float) = 8
|
|
12
|
+
_Stencil ("Stencil ID", Float) = 0
|
|
13
|
+
_StencilOp ("Stencil Operation", Float) = 0
|
|
14
|
+
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
|
15
|
+
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
|
16
|
+
_ColorMask ("Color Mask", Float) = 15
|
|
17
|
+
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
SubShader
|
|
21
|
+
{
|
|
22
|
+
Tags
|
|
23
|
+
{
|
|
24
|
+
"Queue"="Transparent"
|
|
25
|
+
"IgnoreProjector"="True"
|
|
26
|
+
"RenderType"="Transparent"
|
|
27
|
+
"PreviewType"="Plane"
|
|
28
|
+
"CanUseSpriteAtlas"="True"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Stencil
|
|
32
|
+
{
|
|
33
|
+
Ref [_Stencil]
|
|
34
|
+
Comp [_StencilComp]
|
|
35
|
+
Pass [_StencilOp]
|
|
36
|
+
ReadMask [_StencilReadMask]
|
|
37
|
+
WriteMask [_StencilWriteMask]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Cull Off
|
|
41
|
+
Lighting Off
|
|
42
|
+
ZWrite Off
|
|
43
|
+
ZTest [unity_GUIZTestMode]
|
|
44
|
+
Blend SrcAlpha OneMinusSrcAlpha
|
|
45
|
+
ColorMask [_ColorMask]
|
|
46
|
+
|
|
47
|
+
Pass
|
|
48
|
+
{
|
|
49
|
+
Name "Default"
|
|
50
|
+
|
|
51
|
+
CGPROGRAM
|
|
52
|
+
#pragma vertex vert
|
|
53
|
+
#pragma fragment frag
|
|
54
|
+
#pragma target 2.0
|
|
55
|
+
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
|
56
|
+
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
|
57
|
+
|
|
58
|
+
#include "UnityCG.cginc"
|
|
59
|
+
#include "UnityUI.cginc"
|
|
60
|
+
|
|
61
|
+
struct appdata_t
|
|
62
|
+
{
|
|
63
|
+
float4 vertex : POSITION;
|
|
64
|
+
float4 color : COLOR;
|
|
65
|
+
float2 texcoord : TEXCOORD0;
|
|
66
|
+
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
struct v2f
|
|
70
|
+
{
|
|
71
|
+
float4 vertex : SV_POSITION;
|
|
72
|
+
fixed4 color : COLOR;
|
|
73
|
+
float2 texcoord : TEXCOORD0;
|
|
74
|
+
float4 worldPosition : TEXCOORD1;
|
|
75
|
+
float2 localPosition : TEXCOORD2;
|
|
76
|
+
UNITY_VERTEX_OUTPUT_STEREO
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
sampler2D _MainTex;
|
|
80
|
+
fixed4 _Color;
|
|
81
|
+
fixed4 _TextureSampleAdd;
|
|
82
|
+
float4 _ClipRect;
|
|
83
|
+
float4 _MainTex_ST;
|
|
84
|
+
float4 _RectSize;
|
|
85
|
+
float4 _CornerRadii;
|
|
86
|
+
float _Softness;
|
|
87
|
+
|
|
88
|
+
v2f vert(appdata_t v)
|
|
89
|
+
{
|
|
90
|
+
v2f OUT;
|
|
91
|
+
UNITY_SETUP_INSTANCE_ID(v);
|
|
92
|
+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
|
93
|
+
OUT.worldPosition = v.vertex;
|
|
94
|
+
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
|
95
|
+
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
|
96
|
+
OUT.localPosition = v.vertex.xy;
|
|
97
|
+
OUT.color = v.color * _Color;
|
|
98
|
+
return OUT;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fixed4 frag(v2f IN) : SV_Target
|
|
102
|
+
{
|
|
103
|
+
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
|
104
|
+
|
|
105
|
+
float2 rectSize = max(_RectSize.xy, float2(1.0, 1.0));
|
|
106
|
+
float2 halfSize = rectSize * 0.5;
|
|
107
|
+
float2 localPosition = IN.localPosition;
|
|
108
|
+
float4 cornerRadii = max(_CornerRadii, 0.0);
|
|
109
|
+
float softness = max(_Softness, 0.001);
|
|
110
|
+
float rectDistance = max(abs(localPosition.x) - halfSize.x, abs(localPosition.y) - halfSize.y);
|
|
111
|
+
float shapeAlpha = 1.0 - smoothstep(-softness, softness, rectDistance);
|
|
112
|
+
|
|
113
|
+
if (cornerRadii.x > 0.0 && localPosition.x < -halfSize.x + cornerRadii.x && localPosition.y > halfSize.y - cornerRadii.x)
|
|
114
|
+
{
|
|
115
|
+
float2 cornerCenter = float2(-halfSize.x + cornerRadii.x, halfSize.y - cornerRadii.x);
|
|
116
|
+
shapeAlpha *= smoothstep(-softness, softness, cornerRadii.x - length(localPosition - cornerCenter));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (cornerRadii.y > 0.0 && localPosition.x > halfSize.x - cornerRadii.y && localPosition.y > halfSize.y - cornerRadii.y)
|
|
120
|
+
{
|
|
121
|
+
float2 cornerCenter = float2(halfSize.x - cornerRadii.y, halfSize.y - cornerRadii.y);
|
|
122
|
+
shapeAlpha *= smoothstep(-softness, softness, cornerRadii.y - length(localPosition - cornerCenter));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (cornerRadii.z > 0.0 && localPosition.x > halfSize.x - cornerRadii.z && localPosition.y < -halfSize.y + cornerRadii.z)
|
|
126
|
+
{
|
|
127
|
+
float2 cornerCenter = float2(halfSize.x - cornerRadii.z, -halfSize.y + cornerRadii.z);
|
|
128
|
+
shapeAlpha *= smoothstep(-softness, softness, cornerRadii.z - length(localPosition - cornerCenter));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (cornerRadii.w > 0.0 && localPosition.x < -halfSize.x + cornerRadii.w && localPosition.y < -halfSize.y + cornerRadii.w)
|
|
132
|
+
{
|
|
133
|
+
float2 cornerCenter = float2(-halfSize.x + cornerRadii.w, -halfSize.y + cornerRadii.w);
|
|
134
|
+
shapeAlpha *= smoothstep(-softness, softness, cornerRadii.w - length(localPosition - cornerCenter));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
color.a *= shapeAlpha;
|
|
138
|
+
|
|
139
|
+
#ifdef UNITY_UI_CLIP_RECT
|
|
140
|
+
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
|
141
|
+
#endif
|
|
142
|
+
|
|
143
|
+
#ifdef UNITY_UI_ALPHACLIP
|
|
144
|
+
clip(color.a - 0.001);
|
|
145
|
+
#endif
|
|
146
|
+
|
|
147
|
+
return color;
|
|
148
|
+
}
|
|
149
|
+
ENDCG
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
Binary file
|