浏览代码

add some tests.

/main
kg 6 年前
当前提交
49322974
共有 29 个文件被更改,包括 402 次插入373 次删除
  1. 10
      Assets/UIWidgets/Resources/UIWidgets_CG.cginc
  2. 110
      Assets/UIWidgets/Resources/UIWidgets_GUIRoundedRect.shader
  3. 28
      Assets/UIWidgets/ui/painting/editor_canvas.cs
  4. 15
      Assets/UIWidgets/ui/painting/painting.cs
  5. 2
      ProjectSettings/ProjectVersion.txt
  6. 119
      Assets/UIWidgets/Resources/UIWidgets_ShadowRect.shader
  7. 8
      Assets/UIWidgets/Tests.meta
  8. 3
      Assets/UIWidgets/UIWidgets.asmdef
  9. 7
      Assets/UIWidgets/UIWidgets.asmdef.meta
  10. 8
      Assets/UIWidgets/editor.meta
  11. 108
      Assets/UIWidgets/Tests/CanvasAndLayers.cs
  12. 11
      Assets/UIWidgets/Tests/CanvasAndLayers.cs.meta
  13. 10
      Assets/UIWidgets/Tests/Menu.cs
  14. 11
      Assets/UIWidgets/Tests/Menu.cs.meta
  15. 14
      Assets/UIWidgets/Tests/Tests.asmdef
  16. 7
      Assets/UIWidgets/Tests/Tests.asmdef.meta
  17. 76
      Assets/UIWidgets/Resources/UIWidgets_ShadowMat.mat
  18. 8
      Assets/UIWidgets/Resources/UIWidgets_ShadowMat.mat.meta
  19. 119
      Assets/UIWidgets/Resources/UIWidgets_ShadowShader.shader
  20. 77
      Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.mat
  21. 8
      Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.mat.meta
  22. 3
      Assets/UIWidgets/flow/layer_canvas.cs.meta
  23. 10
      Assets/UIWidgets/flow/layer_canvas.cs
  24. 3
      Assets/UIWidgets/editor1.meta
  25. 0
      /Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.shader
  26. 0
      /Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.shader.meta
  27. 0
      /Assets/UIWidgets/Resources/UIWidgets_ShadowRect.shader.meta
  28. 0
      /Assets/UIWidgets/editor

10
Assets/UIWidgets/Resources/UIWidgets_CG.cginc


uniform float4 UIWidgets_GUIClipRect;
uniform float4 UIWidgets_GUIClipRectRadius;
half GetCornerAlpha(float2 p, float2 center, float radius, float pixelScale) {
half __getCornerAlpha (float2 p, float2 center, float radius, float pixelScale) {
half outerDistAlpha = saturate(0.5f + outerDist);
half outerDistAlpha = saturate(0.5f - outerDist);
return 1.0f - outerDistAlpha;
return outerDistAlpha;
float getClipAlpha(float2 p, float pixelScale) {
float getClipAlpha (float2 p, float pixelScale) {
bool xIsLeft = (p.x - UIWidgets_GUIClipRect[0] - UIWidgets_GUIClipRect[2] / 2.0f) <= 0.0f;
bool yIsTop = (p.y - UIWidgets_GUIClipRect[1] - UIWidgets_GUIClipRect[3] / 2.0f) <= 0.0f;

float clipAlpha = 1.0f;
bool isInCorner = (xIsLeft ? p.x <= center.x : p.x >= center.x) && (yIsTop ? p.y <= center.y : p.y >= center.y);
float cornerAlpha = isInCorner ? GetCornerAlpha(p, center, activeRadius, pixelScale) : 1.0f;
float cornerAlpha = isInCorner ? __getCornerAlpha(p, center, activeRadius, pixelScale) : 1.0f;
clipAlpha *= cornerAlpha;
bool isInRect =

110
Assets/UIWidgets/Resources/UIWidgets_GUIRoundedRect.shader


Shader "UIWidgets/GUIRoundedRect"
{
Properties {
_MainTex ("Texture", any) = "white" {}
_MainTex("Texture", any) = "white" {}
_SrcBlend("SrcBlend", Int) = 5 // SrcAlpha
_DstBlend("DstBlend", Int) = 10 // OneMinusSrcAlpha
}

};
sampler2D _MainTex;
sampler2D _GUIClipTexture;
uniform float4 _MainTex_ST;
uniform float4 _MainTex_ST;
uniform float4x4 UIWidgets_GUIClipTextureMatrix[16];
uniform int UIWidgets_GUIClipTextureMatrixCount;
uniform float UIWidgets_CornerRadiuses[4];
uniform float UIWidgets_BorderWidths[4];
half GetCornerAlpha(float2 p, float2 center, float borderWidth1, float borderWidth2, float radius, float pixelScale)
{
bool hasBorder = borderWidth1 > 0.0f || borderWidth2 > 0.0f;
uniform float UIWidgets_BorderWidth[4];
uniform float UIWidgets_CornerRadius[4];
#include "UIWidgets_CG.cginc"
half getCornerAlpha (float2 p, float2 center, float borderWidth1, float borderWidth2, float radius, float pixelScale) {
float pixelCenterDist = length(v);
float outRad = radius;
float outerDist = (pixelCenterDist - outRad) * pixelScale;
half outerDistAlpha = hasBorder ? saturate(0.5f + outerDist) : 0.0f;
float outerDist = (length(v) - radius) * pixelScale;
half outerDistAlpha = saturate(0.5f - outerDist);
bool hasBorder = borderWidth1 > 0.0f || borderWidth2 > 0.0f;
v.y *= a/b;
v.y *= a / b;
half alpha = saturate(rawDist+0.5f);
half innerDistAlpha = hasBorder ? ((a > 0 && b > 0) ? alpha : 1.0f) : 0.0f;
half alpha = saturate(0.5f + rawDist);
half innerDistAlpha = (hasBorder && a > 0 && b > 0) ? alpha : 1.0f;
return (outerDistAlpha == 0.0f) ? innerDistAlpha : (1.0f - outerDistAlpha);
return (outerDistAlpha == 1.0f) ? innerDistAlpha : outerDistAlpha;
bool IsPointInside(float2 p, float4 rect)
{
bool isPointInside (float2 p, float4 rect) {
v2f vert (appdata_t v)
{
float3 eyePos = UnityObjectToViewPos(v.vertex);
v2f vert (appdata_t v) {
o.clipUV = float4(eyePos.xy, 0, 1.0);
float3 eyePos = UnityObjectToViewPos(v.vertex);
o.clipUV = mul(UIWidgets_GUIClipMatrix, float4(eyePos.xy, 0, 1.0));
fixed4 frag (v2f i) : SV_Target
{
float pixelScale = 1.0f/abs(ddx(i.pos.x));
fixed4 frag (v2f i) : SV_Target {
if (_ManualTex2SRGB)
if (_ManualTex2SRGB) {
}
bool xIsLeft = (p.x - _Rect[0] - _Rect[2]/2.0f) <= 0.0f;
bool yIsTop = (p.y - _Rect[1] - _Rect[3]/2.0f) <= 0.0f;
bool xIsLeft = (p.x - _Rect[0] - _Rect[2] / 2.0f) <= 0.0f;
bool yIsTop = (p.y - _Rect[1] - _Rect[3] / 2.0f) <= 0.0f;
float bw1 = UIWidgets_BorderWidths[0];
float bw2 = UIWidgets_BorderWidths[1];
float bw1 = UIWidgets_BorderWidth[0];
float bw2 = UIWidgets_BorderWidth[1];
if (xIsLeft)
if (xIsLeft) {
else
} else {
}
float activeRadius = UIWidgets_CornerRadiuses[radiusIndex];
float2 center = float2(_Rect[0]+activeRadius, _Rect[1]+activeRadius);
float activeRadius = UIWidgets_CornerRadius[radiusIndex];
float2 center = float2(_Rect[0] + activeRadius, _Rect[1] + activeRadius);
if (!xIsLeft)
{
center.x = (_Rect[0]+_Rect[2]-activeRadius);
bw1 = UIWidgets_BorderWidths[2];
if (!xIsLeft) {
center.x = (_Rect[0] + _Rect[2] - activeRadius);
bw1 = UIWidgets_BorderWidth[2];
if (!yIsTop)
{
center.y = (_Rect[1]+_Rect[3]-activeRadius);
bw2 = UIWidgets_BorderWidths[3];
if (!yIsTop) {
center.y = (_Rect[1] + _Rect[3] - activeRadius);
bw2 = UIWidgets_BorderWidth[3];
float cornerAlpha = isInCorner ? GetCornerAlpha(p, center, bw1, bw2, activeRadius, pixelScale) : 1.0f;
float pixelScale = 1.0f / abs(ddx(i.pos.x));
float cornerAlpha = isInCorner ? getCornerAlpha(p, center, bw1, bw2, activeRadius, pixelScale) : 1.0f;
float4 centerRect = float4(_Rect[0]+UIWidgets_BorderWidths[0], _Rect[1]+UIWidgets_BorderWidths[1], _Rect[2]-(UIWidgets_BorderWidths[0]+UIWidgets_BorderWidths[2]), _Rect[3]-(UIWidgets_BorderWidths[1]+UIWidgets_BorderWidths[3]));
bool isPointInCenter = IsPointInside(p, centerRect);
float4 centerRect = float4(
_Rect[0] + UIWidgets_BorderWidth[0],
_Rect[1] + UIWidgets_BorderWidth[1],
_Rect[2] - (UIWidgets_BorderWidth[0] + UIWidgets_BorderWidth[2]),
_Rect[3] - (UIWidgets_BorderWidth[1] + UIWidgets_BorderWidth[3]));
bool isPointInCenter = isPointInside(p, centerRect);
bool hasBorder = UIWidgets_BorderWidths[0] > 0 || UIWidgets_BorderWidths[1] > 0 || UIWidgets_BorderWidths[2] > 0 || UIWidgets_BorderWidths[3] > 0;
bool hasBorder = UIWidgets_BorderWidth[0] > 0 || UIWidgets_BorderWidth[1] > 0 || UIWidgets_BorderWidth[2] > 0 || UIWidgets_BorderWidth[3] > 0;
float clipAlpha = 1.0f;
for (int idx = 0; idx < UIWidgets_GUIClipTextureMatrixCount; idx++) {
float2 clipUV = mul(UIWidgets_GUIClipTextureMatrix[idx], i.clipUV);
clipAlpha *= tex2D(_GUIClipTexture, clipUV).a;
}
pixelScale = 1.0f / abs(ddx(i.clipUV.x));
float clipAlpha = getClipAlpha(i.clipUV, pixelScale);
if (_SrcBlend != 5) // 5 SrcAlpha
{
if (_SrcBlend != 5) { // 5 SrcAlpha
col.rgb *= cornerAlpha * borderAlpha * clipAlpha;
}
return col;

28
Assets/UIWidgets/ui/painting/editor_canvas.cs


EditorCanvas.guiTextureClipMat = new Material(shader);
EditorCanvas.guiTextureClipMat.hideFlags = HideFlags.HideAndDontSave;
shader = Shader.Find("UIWidgets/ShadowRect");
if (shader == null) {
throw new Exception("UIWidgets/ShadowRect not found");
}
EditorCanvas.shadowRectMat = new Material(shader);
EditorCanvas.shadowRectMat.hideFlags = HideFlags.HideAndDontSave;
private static readonly Material shadowRectMat;
private Matrix4x4 _transform;
private ClipRec _clipRec;

}
public void drawRect(Rect rect, BorderWidth borderWidth, BorderRadius borderRadius, Paint paint) {
throw new NotImplementedException();
this.prepareGL(EditorCanvas.guiRoundedRectMat);
EditorCanvas.guiRoundedRectMat.SetFloatArray("UIWidgets_BorderWidth",
borderWidth == null ? new[] {0f, 0f, 0f, 0f} : borderWidth.toFloatArray());
EditorCanvas.guiRoundedRectMat.SetFloatArray("UIWidgets_CornerRadius",
borderRadius == null ? new[] {0f, 0f, 0f, 0f} : borderRadius.toFloatArray());
Graphics.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture,
new UnityEngine.Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0,
paint.color.toColor(), EditorCanvas.guiRoundedRectMat);
throw new NotImplementedException();
this.prepareGL(EditorCanvas.shadowRectMat);
EditorCanvas.shadowRectMat.SetFloat("UIWidgets_sigma", (float) paint.blurSigma);
Graphics.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture,
new UnityEngine.Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0,
paint.color.toColor(), EditorCanvas.shadowRectMat);
}
public void drawPicture(Picture picture) {

15
Assets/UIWidgets/ui/painting/painting.cs


(float) borderWidth.bottom);
}
public static float[] toFloatArray(this BorderWidth borderWidth) {
return new[] {
(float) borderWidth.left, (float) borderWidth.top,
(float) borderWidth.right, (float) borderWidth.bottom
};
}
}
public static float[] toFloatArray(this BorderRadius borderRadius) {
return new[] {
(float) borderRadius.topLeft, (float) borderRadius.topRight,
(float) borderRadius.bottomRight, (float) borderRadius.bottomLeft
};
}
}

2
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2018.2.0f2
m_EditorVersion: 2018.2.4f1

119
Assets/UIWidgets/Resources/UIWidgets_ShadowRect.shader


Shader "UIWidgets/ShadowRect"
{
Properties {
_MainTex("Texture", any) = "white" {}
_SrcBlend("SrcBlend", Int) = 5 // SrcAlpha
_DstBlend("DstBlend", Int) = 10 // OneMinusSrcAlpha
}
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#pragma target 2.5
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 clipUV : TEXCOORD1;
float4 pos : TEXCOORD2;
};
sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform bool _ManualTex2SRGB;
uniform int _SrcBlend;
uniform float _Rect[4];
uniform float UIWidgets_sigma;
#include "UIWidgets_CG.cginc"
// http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
float4 erf (float4 x) {
float4 s = sign(x);
float4 a = abs(x);
x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a;
x *= x;
return s - s / (x * x);
}
float UIWidgets_boxShadow (float2 lower, float2 upper, float2 pos, float sigma) {
float4 query = float4((lower - pos).xy, (upper - pos).xy);
float4 integral = erf(query * (sqrt(0.5) / sigma)) * 0.5 + 0.5;
return (integral.z - integral.x) * (integral.w - integral.y);
}
v2f vert (appdata_t v) {
float3 eyePos = UnityObjectToViewPos(v.vertex);
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
o.clipUV = mul(UIWidgets_GUIClipMatrix, float4(eyePos.xy, 0, 1.0));
o.pos = v.vertex;
return o;
}
fixed4 frag (v2f i) : SV_Target {
half4 col = tex2D(_MainTex, i.texcoord);
if (_ManualTex2SRGB) {
col.rgb = LinearToGammaSpace(col.rgb);
}
col *= i.color;
float2 p = i.pos.xy;
float shadowAlpha = UIWidgets_boxShadow(
float2(_Rect[0] + 3 * UIWidgets_sigma, _Rect[1] + 3 * UIWidgets_sigma),
float2(_Rect[0] + _Rect[2] - 3 * UIWidgets_sigma, _Rect[1] + _Rect[3] - 3 * UIWidgets_sigma),
p, UIWidgets_sigma);
col.a *= shadowAlpha;
float pixelScale = 1.0f / abs(ddx(i.clipUV.x));
float clipAlpha = getClipAlpha(i.clipUV, pixelScale);
col.a *= clipAlpha;
// If the source blend is not SrcAlpha (default) we need to multiply the color by the rounded corner
// alpha factors for clipping, since it will not be done at the blending stage.
if (_SrcBlend != 5) { // 5 SrcAlpha
col.rgb *= shadowAlpha * clipAlpha;
}
return col;
}
ENDCG
SubShader {
Blend [_SrcBlend] [_DstBlend], One OneMinusSrcAlpha
Cull Off
ZWrite Off
ZTest Always
Pass {
CGPROGRAM
ENDCG
}
}
SubShader {
Blend [_SrcBlend] [_DstBlend]
Cull Off
ZWrite Off
ZTest Always
Pass {
CGPROGRAM
ENDCG
}
}
FallBack "UIWidgets/GUITextureClip"
}

8
Assets/UIWidgets/Tests.meta


fileFormatVersion: 2
guid: 49a5e2d0e7a21443bba549be43719c88
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Assets/UIWidgets/UIWidgets.asmdef


{
"name": "UIWidgets"
}

7
Assets/UIWidgets/UIWidgets.asmdef.meta


fileFormatVersion: 2
guid: 8f067a12d23d84440a407989da39a9c5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/UIWidgets/editor.meta


fileFormatVersion: 2
guid: a9499ff15faa04b8cb4281fab5a966f1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

108
Assets/UIWidgets/Tests/CanvasAndLayers.cs


using System;
using System.Linq;
using UIWidgets.painting;
using UIWidgets.ui;
using UnityEditor;
using UnityEngine;
using Color = UIWidgets.ui.Color;
using Rect = UIWidgets.ui.Rect;
namespace Editor.Tests {
public class CanvasAndLayers : EditorWindow {
private readonly Action[] _options;
private readonly string[] _optionStrings;
private int _selected;
CanvasAndLayers() {
this._options = new Action[] {
this.drawPloygon4,
this.drawRect,
this.drawRectShadow,
this.drawPicture,
};
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray();
this._selected = 0;
this.titleContent = new GUIContent("CanvasAndLayers");
}
void OnGUI() {
this._selected = EditorGUILayout.Popup("test case", this._selected, this._optionStrings);
this._options[this._selected]();
}
void drawPloygon4() {
var canvas = new EditorCanvas();
var paint = new Paint {
color = new Color(0xFFFF0000),
};
canvas.drawPloygon4(
new[] {new Offset(10, 10), new Offset(10, 110), new Offset(110, 110), new Offset(110, 10)},
paint);
canvas.drawPloygon4(
new[] {new Offset(10, 150), new Offset(10, 160), new Offset(140, 120), new Offset(110, 180)},
paint);
}
void drawRect() {
var canvas = new EditorCanvas();
var paint = new Paint {
color = new Color(0xFFFF0000),
};
canvas.drawRect(
Rect.fromLTWH(10, 10, 100, 100),
BorderWidth.only(2, 4, 6, 8),
BorderRadius.only(0, 4, 8, 16),
paint);
paint = new Paint {
color = new Color(0xFF00FF00),
};
canvas.drawRect(
Rect.fromLTWH(10, 150, 100, 100),
BorderWidth.only(),
BorderRadius.only(0, 4, 8, 16),
paint);
canvas.drawRect(
Rect.fromLTWH(150, 150, 100, 100),
BorderWidth.only(10, 12, 14, 16),
BorderRadius.only(),
paint);
}
void drawRectShadow() {
var canvas = new EditorCanvas();
var paint = new Paint {
color = new Color(0xFF00FF00),
blurSigma = 3.0,
};
canvas.drawRectShadow(
Rect.fromLTWH(10, 10, 100, 100),
paint);
paint = new Paint {
color = new Color(0xFFFFFF00),
blurSigma = 2.0,
};
canvas.drawRectShadow(
Rect.fromLTWH(10, 150, 100, 100),
paint);
}
void drawPicture() {
}
}
}

11
Assets/UIWidgets/Tests/CanvasAndLayers.cs.meta


fileFormatVersion: 2
guid: 670ec19e3d68342e985db21ef957463c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

10
Assets/UIWidgets/Tests/Menu.cs


using UnityEditor;
namespace Editor.Tests {
public static class Menu {
[MenuItem("UIWidgetsTests/CanvasAndLayers")]
public static void canvasAndLayers() {
EditorWindow.GetWindow(typeof(CanvasAndLayers));
}
}
}

11
Assets/UIWidgets/Tests/Menu.cs.meta


fileFormatVersion: 2
guid: a00837aa7e8a44daeb1df672601c872c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

14
Assets/UIWidgets/Tests/Tests.asmdef


{
"name": "Tests",
"references": [
"UIWidgets"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}

7
Assets/UIWidgets/Tests/Tests.asmdef.meta


fileFormatVersion: 2
guid: 32fc967a48d0e4e0ab4c508341f24e2e
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

76
Assets/UIWidgets/Resources/UIWidgets_ShadowMat.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UIWidgets_ShadowMat
m_Shader: {fileID: 4800000, guid: 1f7a328e0f36042d89a5781d0a2b9cdf, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

8
Assets/UIWidgets/Resources/UIWidgets_ShadowMat.mat.meta


fileFormatVersion: 2
guid: 8fb13a939b26349648cac189e4b8b0c0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

119
Assets/UIWidgets/Resources/UIWidgets_ShadowShader.shader


Shader "UIWidgets/ShadowShader"
{
Properties {
_MainTex ("Texture", any) = "white" {}
_SrcBlend("SrcBlend", Int) = 5 // SrcAlpha
_DstBlend("DstBlend", Int) = 10 // OneMinusSrcAlpha
}
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#pragma target 2.5
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 clipUV : TEXCOORD1;
float4 pos : TEXCOORD2;
};
sampler2D _MainTex;
sampler2D _GUIClipTexture;
uniform bool _ManualTex2SRGB;
uniform int _SrcBlend;
uniform float4 _MainTex_ST;
uniform float4x4 unity_GUIClipTextureMatrix;
uniform float _Rect[4];
uniform float _sigma;
// http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
float4 erf (float4 x) {
float4 s = sign(x);
float4 a = abs(x);
x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a;
x *= x;
return s - s / (x * x);
}
float boxShadow1 (float2 lower, float2 upper, float2 pos, float sigma) {
float4 query = float4((lower - pos).xy, (upper - pos).xy);
float4 integral = erf(query * (sqrt(0.5) / sigma)) * 0.5 + 0.5;
return (integral.z - integral.x) * (integral.w - integral.y);
}
v2f vert (appdata_t v) {
float3 eyePos = UnityObjectToViewPos(v.vertex);
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
o.pos = v.vertex;
return o;
}
fixed4 frag (v2f i) : SV_Target {
half4 col = tex2D(_MainTex, i.texcoord);
if (_ManualTex2SRGB)
col.rgb = LinearToGammaSpace(col.rgb);
col *= i.color;
float2 p = i.pos.xy;
float clipAlpha = tex2D(_GUIClipTexture, i.clipUV).a;
col.a *= clipAlpha;
float shadowAlpha = boxShadow1(
float2(_Rect[0] + 3 * _sigma, _Rect[1] + 3 * _sigma),
float2(_Rect[0] + _Rect[2] - 3 * _sigma, _Rect[1] + _Rect[3] - 3 * _sigma),
p, _sigma);
col.a *= shadowAlpha;
// If the source blend is not SrcAlpha (default) we need to multiply the color by the rounded corner
// alpha factors for clipping, since it will not be done at the blending stage.
if (_SrcBlend != 5) { // 5 SrcAlpha
col.rgb *= clipAlpha;
}
return col;
}
ENDCG
SubShader {
Blend [_SrcBlend] [_DstBlend], One OneMinusSrcAlpha
Cull Off
ZWrite Off
ZTest Always
Pass {
CGPROGRAM
ENDCG
}
}
SubShader {
Blend [_SrcBlend] [_DstBlend]
Cull Off
ZWrite Off
ZTest Always
Pass {
CGPROGRAM
ENDCG
}
}
FallBack "Hidden/Internal-GUITextureClip"
}

77
Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UIWidgets_2DHandlesLines
m_Shader: {fileID: 4800000, guid: 81e78a346e6a4cad9c4fcc54da649074, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HandleZTest: 8
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

8
Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.mat.meta


fileFormatVersion: 2
guid: 30a1a0c9df8e6493e8df8cab5dd1adbe
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

3
Assets/UIWidgets/flow/layer_canvas.cs.meta


fileFormatVersion: 2
guid: cde8bcfaf053454e96be846b7506df05
timeCreated: 1534475158

10
Assets/UIWidgets/flow/layer_canvas.cs


using System;
using System.Collections.Generic;
using UIWidgets.ui;
using UnityEditor;
using UnityEngine;
using Rect = UIWidgets.ui.Rect;
namespace UIWidgets.flow {
}

3
Assets/UIWidgets/editor1.meta


fileFormatVersion: 2
guid: 531a69a207e64172959ffbed66131560
timeCreated: 1534308241

/Assets/UIWidgets/Resources/UIWidgets_2DHandlesLinesShader.shader → /Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.shader

/Assets/UIWidgets/Resources/UIWidgets_2DHandlesLinesShader.shader.meta → /Assets/UIWidgets/Resources/UIWidgets_2DHandlesLines.shader.meta

/Assets/UIWidgets/Resources/UIWidgets_ShadowShader.shader.meta → /Assets/UIWidgets/Resources/UIWidgets_ShadowRect.shader.meta

/Assets/UIWidgets/editor1 → /Assets/UIWidgets/editor

正在加载...
取消
保存