浏览器嵌入,国旗文件
This commit is contained in:
1 parent
e7a3214cb5
commit
07feba912c
552 files changed
+39279
-8128
No files matched your search
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f5e42e9e114a0e4abdf39588a33a9dc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class ImageWithRoundedCorners : MonoBehaviour {
|
||||
private static readonly int Props = Shader.PropertyToID("_WidthHeightRadius");
|
||||
|
||||
private Material material;
|
||||
public float radius;
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
void OnRectTransformDimensionsChange(){
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void OnValidate(){
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void Refresh(){
|
||||
if (material != null)
|
||||
{
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Props, new Vector4(rect.width, rect.height, radius*2, 0));
|
||||
if (gameObject.GetComponent<Image>() != null)
|
||||
{
|
||||
gameObject.GetComponent<Image>().material = material;
|
||||
gameObject.GetComponent<Image>().sprite = null;
|
||||
}
|
||||
else if (gameObject.GetComponent<RawImage>()!=null)
|
||||
{
|
||||
gameObject.GetComponent<RawImage>().material = material;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adb30198aa32dd140b5750692dd48104
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
Shader "UI/RoundedCorners/RoundedCorners" {
|
||||
Properties {
|
||||
[HideInInspector] _MainTex ("Texture", 2D) = "white" {}
|
||||
|
||||
// --- Mask support ---
|
||||
[HideInInspector] _StencilComp ("Stencil Comparison", Float) = 8
|
||||
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
|
||||
[HideInInspector] _StencilOp ("Stencil Operation", Float) = 0
|
||||
[HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
[HideInInspector] _ColorMask ("Color Mask", Float) = 15
|
||||
[HideInInspector] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Definition in Properties section is required to Mask works properly
|
||||
_WidthHeightRadius ("WidthHeightRadius", Vector) = (0,0,0,0)
|
||||
// ---
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Transparent"
|
||||
"Queue"="Transparent"
|
||||
}
|
||||
|
||||
// --- Mask support ---
|
||||
Stencil {
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ColorMask [_ColorMask]
|
||||
// ---
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "SDFUtils.cginc"
|
||||
#include "ShaderSetup.cginc"
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
float4 _WidthHeightRadius;
|
||||
sampler2D _MainTex;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
float alpha = CalcAlpha(i.uv, _WidthHeightRadius.xy, _WidthHeightRadius.z);
|
||||
return mixAlpha(tex2D(_MainTex, i.uv), i.color, alpha);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bd2ec5d73751e34a814274a454bec41
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,82 +0,0 @@
|
||||
// SDF Function for rectangle
|
||||
float rectangle(float2 samplePosition, float2 halfSize){
|
||||
// X component represents signed distance to closest vertical edge of rectangle
|
||||
// Same for Y but for closest horizontal edge
|
||||
// HalfSize represents two distances from each axis of 2d space to a сorresponding edge
|
||||
float2 distanceToEdge = abs(samplePosition) - halfSize;
|
||||
// max(n, 0) to remove distances that signed with minus (distances inside rectangle)
|
||||
// length to calculate distance from outside (distances that > 0) to rectangle
|
||||
float outsideDistance = length(max(distanceToEdge, 0));
|
||||
// max(x,y) is a cheap way to calculate distance to closest edge inside rectangle
|
||||
// with min we just make sure that inside distances would not impact on outside distances
|
||||
float insideDistance = min(max(distanceToEdge.x, distanceToEdge.y), 0);
|
||||
return outsideDistance + insideDistance;
|
||||
}
|
||||
|
||||
// An extension of rectangle() function to modify signed distance (effect as a wrap around rectangle)
|
||||
float roundedRectangle(float2 samplePosition, float absoluteRound, float2 halfSize){
|
||||
// subtrancting value from final distance effects like a wrap around rectangle, so
|
||||
// the solution is to decrease actual rectangle with `absoluteRound` value
|
||||
// and then make an effect of wrap with size of `absoluteRound`
|
||||
return rectangle(samplePosition, halfSize - absoluteRound) - absoluteRound;
|
||||
}
|
||||
|
||||
// Smoothstep function with antialiasing
|
||||
float AntialiasedCutoff(float distance){
|
||||
float distanceChange = fwidth(distance) * 0.5;
|
||||
return smoothstep(distanceChange, -distanceChange, distance);
|
||||
}
|
||||
|
||||
float CalcAlpha(float2 samplePosition, float2 size, float radius){
|
||||
// -.5 = translate origin of samplePositions from (0, 0) to (.5, .5)
|
||||
// because for Image component (0,0) is bottom-right, not a center
|
||||
// * size = scale samplePositions to localSpace of Image with this size
|
||||
float2 samplePositionTranslated = (samplePosition - .5) * size;
|
||||
float distToRect = roundedRectangle(samplePositionTranslated, radius * .5, size * .5);
|
||||
return AntialiasedCutoff(distToRect);
|
||||
}
|
||||
|
||||
inline float2 translate(float2 samplePosition, float2 offset){
|
||||
return samplePosition - offset;
|
||||
}
|
||||
|
||||
float intersect(float shape1, float shape2){
|
||||
return max(shape1, shape2);
|
||||
}
|
||||
|
||||
float2 rotate(float2 samplePosition, float rotation){
|
||||
const float PI = 3.14159;
|
||||
float angle = rotation * PI * 2 * -1;
|
||||
float sine, cosine;
|
||||
sincos(angle, sine, cosine);
|
||||
return float2(cosine * samplePosition.x + sine * samplePosition.y, cosine * samplePosition.y - sine * samplePosition.x);
|
||||
}
|
||||
|
||||
float circle(float2 position, float radius){
|
||||
return length(position) - radius;
|
||||
}
|
||||
|
||||
float CalcAlphaForIndependentCorners(float2 samplePosition, float2 halfSize, float4 rect2props, float4 r){
|
||||
|
||||
samplePosition = (samplePosition - .5) * halfSize * 2;
|
||||
|
||||
float r1 = rectangle(samplePosition, halfSize);
|
||||
|
||||
float2 r2Position = rotate(translate(samplePosition, rect2props.xy), .125);
|
||||
float r2 = rectangle(r2Position, rect2props.zw);
|
||||
|
||||
float2 circle0Position = translate(samplePosition, float2(-halfSize.x + r.x, halfSize.y - r.x));
|
||||
float c0 = circle(circle0Position, r.x);
|
||||
|
||||
float2 circle1Position = translate(samplePosition, float2(halfSize.x - r.y, halfSize.y - r.y));
|
||||
float c1 = circle(circle1Position, r.y);
|
||||
|
||||
float2 circle2Position = translate(samplePosition, float2(halfSize.x - r.z, -halfSize.y + r.z));
|
||||
float c2 = circle(circle2Position, r.z);
|
||||
|
||||
float2 circle3Position = translate(samplePosition, -halfSize + r.w);
|
||||
float c3 = circle(circle3Position, r.w);
|
||||
|
||||
float dist = max(r1,min(min(min(min(r2, c0), c1), c2), c3));
|
||||
return AntialiasedCutoff(dist);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab2727997695a3f47805a77e7bf398fd
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR; // set from Image component property
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
inline fixed4 mixAlpha(fixed4 mainTexColor, fixed4 color, float sdfAlpha){
|
||||
fixed4 col = mainTexColor * color;
|
||||
col.a = min(col.a, sdfAlpha);
|
||||
return col;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33563ecef438258418542aa6f49c18c6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user