添加debug工具

This commit is contained in:
2024-09-03 19:56:21 +08:00
parent 187407cedb
commit aa4595f290
554 changed files with 59600 additions and 9992 deletions

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b0daca6285f51cd4eab91ffd8980c529
folderAsset: yes
timeCreated: 1505891693
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,233 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &144440
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 22434076}
- component: {fileID: 22230716}
- component: {fileID: 11463902}
m_Layer: 5
m_Name: Selector_In
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &154636
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 22415502}
- component: {fileID: 22203708}
- component: {fileID: 11400054}
- component: {fileID: 11458508}
m_Layer: 5
m_Name: ColorWheel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &155348
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 22430678}
- component: {fileID: 22201174}
- component: {fileID: 11484078}
m_Layer: 5
m_Name: Selector_Out
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &11400054
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 154636}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: 412232a98a56d684a9350a77ef21058d, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &11458508
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 154636}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ed2c6afe74ecb7548b7c676d57a2373c, type: 3}
m_Name:
m_EditorClassIdentifier:
SelectorOut: {fileID: 22430678}
SelectorIn: {fileID: 22434076}
--- !u!114 &11463902
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 144440}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: f577070d7be21e24e9ed69d3c5f2c20c, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &11484078
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155348}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: f577070d7be21e24e9ed69d3c5f2c20c, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &22201174
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155348}
--- !u!222 &22203708
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 154636}
--- !u!222 &22230716
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 144440}
--- !u!224 &22415502
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 154636}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 22430678}
- {fileID: 22434076}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 250, y: 250}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &22430678
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155348}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22415502}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 12.5, y: 12.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &22434076
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 144440}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22415502}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 12.5, y: 12.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 154636}
m_IsPrefabParent: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: af8ebf3eda3f41146bb902219c03964f
timeCreated: 1429524040
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,207 @@
// Copyright (c) 2015, Felix Kate All rights reserved.
// Usage of this code is governed by a BSD-style license that can be found in the LICENSE file.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace RuntimeInspectorNamespace
{
public class ColorWheelControl : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
{
private const float RGB_CONST = 2 / Mathf.PI;
private const float G_CONST = 2 * Mathf.PI * ( 1.0f / 3.0f );
private const float B_CONST = 2 * Mathf.PI * ( 2.0f / 3.0f );
private Color m_color;
public Color Color
{
get { return m_color; }
private set
{
if( m_color != value )
{
m_color = value;
m_color.a = Alpha;
if( OnColorChanged != null )
OnColorChanged( m_color );
}
}
}
public float Alpha { get; set; }
private RectTransform rectTransform;
#pragma warning disable 0649
[SerializeField]
private RectTransform SelectorOut;
[SerializeField]
private RectTransform SelectorIn;
[SerializeField]
private WindowDragHandler colorPickerWindow;
#pragma warning restore 0649
private float outer;
private Vector2 inner;
private Material mat;
private bool draggingOuter, draggingInner;
private float halfSize, halfSizeSqr, outerCirclePaddingSqr, innerSquareHalfSize;
private int pointerId = -98765;
public delegate void OnColorChangedDelegate( Color32 color );
public event OnColorChangedDelegate OnColorChanged;
private void Awake()
{
rectTransform = (RectTransform) transform;
Image img = GetComponent<Image>();
mat = new Material( img.material );
img.material = mat;
UpdateProperties();
}
private void OnRectTransformDimensionsChange()
{
if( rectTransform == null )
return;
UpdateProperties();
UpdateSelectors();
}
private void UpdateProperties()
{
halfSize = rectTransform.rect.size.x * 0.5f;
halfSizeSqr = halfSize * halfSize;
outerCirclePaddingSqr = halfSizeSqr * 0.75f * 0.75f;
innerSquareHalfSize = halfSize * 0.5f;
}
public void PickColor( Color c )
{
Alpha = c.a;
float h, s, v;
Color.RGBToHSV( c, out h, out s, out v );
outer = h * 2f * Mathf.PI;
inner.x = 1 - s;
inner.y = 1 - v;
UpdateSelectors();
Color = c;
mat.SetColor( "_Color", GetCurrentBaseColor() );
}
public void OnPointerDown( PointerEventData eventData )
{
Vector2 position;
if( !RectTransformUtility.ScreenPointToLocalPointInRectangle( rectTransform, eventData.position, eventData.pressEventCamera, out position ) )
return;
//Check if click was in outer circle, inner box or neither
float distanceSqr = position.sqrMagnitude;
if( distanceSqr <= halfSizeSqr && distanceSqr >= outerCirclePaddingSqr )
draggingOuter = true;
else if( Mathf.Abs( position.x ) <= innerSquareHalfSize && Mathf.Abs( position.y ) <= innerSquareHalfSize )
draggingInner = true;
else //Invalid touch, don't track
return;
GetSelectedColor( position );
pointerId = eventData.pointerId;
}
public void OnDrag( PointerEventData eventData )
{
if( pointerId != eventData.pointerId )
{
eventData.pointerDrag = colorPickerWindow.gameObject;
colorPickerWindow.OnBeginDrag( eventData );
return;
}
Vector2 position;
RectTransformUtility.ScreenPointToLocalPointInRectangle( rectTransform, eventData.position, eventData.pressEventCamera, out position );
GetSelectedColor( position );
}
public void OnPointerUp( PointerEventData eventData )
{
if( pointerId != eventData.pointerId )
return;
Vector2 position;
RectTransformUtility.ScreenPointToLocalPointInRectangle( rectTransform, eventData.position, eventData.pressEventCamera, out position );
GetSelectedColor( position );
draggingOuter = false;
draggingInner = false;
pointerId = -98765;
}
private void GetSelectedColor( Vector2 pointerPos )
{
if( draggingOuter )
{
Vector2 dir = -pointerPos.normalized;
outer = Mathf.Atan2( -dir.x, -dir.y );
UpdateColor();
}
else if( draggingInner )
{
Vector2 dir = -pointerPos;
dir.x = Mathf.Clamp( dir.x, -innerSquareHalfSize, innerSquareHalfSize ) + innerSquareHalfSize;
dir.y = Mathf.Clamp( dir.y, -innerSquareHalfSize, innerSquareHalfSize ) + innerSquareHalfSize;
inner = dir / halfSize;
UpdateColor();
}
UpdateSelectors();
}
private void UpdateColor()
{
Color c = GetCurrentBaseColor();
mat.SetColor( "_Color", c );
c = Color.Lerp( c, Color.white, inner.x );
c = Color.Lerp( c, Color.black, inner.y );
Color = c;
}
private Color GetCurrentBaseColor()
{
Color color = Color.white;
//Calculation of rgb from degree with a modified 3 wave function
//Check out http://en.wikipedia.org/wiki/File:HSV-RGB-comparison.svg to understand how it should look
color.r = Mathf.Clamp( RGB_CONST * Mathf.Asin( Mathf.Cos( outer ) ) * 1.5f + 0.5f, 0f, 1f );
color.g = Mathf.Clamp( RGB_CONST * Mathf.Asin( Mathf.Cos( G_CONST - outer ) ) * 1.5f + 0.5f, 0f, 1f );
color.b = Mathf.Clamp( RGB_CONST * Mathf.Asin( Mathf.Cos( B_CONST - outer ) ) * 1.5f + 0.5f, 0f, 1f );
return color;
}
private void UpdateSelectors()
{
SelectorOut.anchoredPosition = new Vector2( Mathf.Sin( outer ) * halfSize * 0.85f, Mathf.Cos( outer ) * halfSize * 0.85f );
SelectorIn.anchoredPosition = new Vector2( innerSquareHalfSize - inner.x * halfSize, innerSquareHalfSize - inner.y * halfSize );
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ed2c6afe74ecb7548b7c676d57a2373c
timeCreated: 1429517417
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,27 @@
Copyright (c) 2015, Felix Kate
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Unity_ColorWheel nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd20edc15d6b63c468da09ded7ed8ed5
timeCreated: 1430238877
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2e85b56eeb74ca74d9cfc5a72750d0d2
folderAsset: yes
timeCreated: 1505899421
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: f577070d7be21e24e9ed69d3c5f2c20c
timeCreated: 1505893949
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,75 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: ColorWheelMaterial
m_Shader: {fileID: 4800000, guid: 9b76b6ef36124ee43b115ddf566992c5, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
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:
- _BorderWhiteness: 1
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EmissionScaleUI: 0
- _Glossiness: 0.5
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 1, b: 0.88534933, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColorUI: {r: 1, g: 1, b: 1, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 412232a98a56d684a9350a77ef21058d
timeCreated: 1429510354
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,169 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
//Copyright (c) 2015, Felix Kate All rights reserved.
// Usage of this code is governed by a BSD-style license that can be found in the LICENSE file.
Shader "UI/ColorWheel"
{
Properties
{
_MainTex("Dummy", 2D) = "white" { }
_Color ("Color", Color) = (1,1,1,1)
//_BorderWhiteness ("Border Whiteness", Range(0.0,1.0)) = 1.0
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.5
#include "UnityCG.cginc"
//Prepare the inputs
struct vertIN
{
float4 vertex : POSITION;
float4 texcoord0 : TEXCOORD0;
};
struct fragIN
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
//Function for making smooth circles from gradient
fixed smoothCircle(fixed size, fixed gradient)
{
fixed scaleFactor = size + 1;
return smoothstep(0.5 - 0.0025 * scaleFactor, 0.5 + 0.0025 * scaleFactor, 1 - gradient * scaleFactor);
}
//Function for making box from gradient
fixed smoothBox(fixed size, fixed2 gradient)
{
fixed scaleFactor = size * 0.5;
fixed alpha = ceil(gradient.x - scaleFactor);
alpha *= ceil((1 - gradient.x) - scaleFactor);
alpha *= ceil(gradient.y - scaleFactor);
alpha *= ceil((1 - gradient.y) - scaleFactor);
return alpha;
}
//Get the values from outside
sampler2D _MainTex;
fixed4 _Color;
//fixed _BorderWhiteness;
//Fill the vert struct
fragIN vert (vertIN v)
{
fragIN o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord0;
return o;
}
//Draw the circle
fixed4 frag(fragIN i) : COLOR
{
fixed4 c = 1;// _BorderWhiteness1;
//Make the inner area of the box
fixed2 bGrad = 1;
bGrad.x = smoothstep(0.25, 0.75, i.uv.x);
bGrad.y = smoothstep(0.25, 0.75, i.uv.y);
fixed4 cBox = lerp(1, _Color, bGrad.x) * bGrad.y;
//Set up PI
fixed PI = 3.14159265359;
fixed PI_INV = 3 / PI;
//Circular gradient
fixed cGrad = distance(i.uv, fixed2(0.5, 0.5));
//Angle gradient
fixed ang = atan2(1 - i.uv.x - 0.5, 1 - i.uv.y - 0.5) + PI;
//Calculate hue
fixed4 cWheel = 1;
cWheel.r = clamp(PI_INV * asin(clamp(cos(ang), -0.99, 0.99)) + 0.5, 0, 1); // 0.01 flexibility -> fixes precision issues on WebGL
cWheel.g = clamp(PI_INV * asin(clamp(cos(2 * PI / 3.0 - ang), -0.99, 0.99)) + 0.5, 0, 1);
cWheel.b = clamp(PI_INV * asin(clamp(cos(4 * PI / 3.0 - ang), -0.99, 0.99)) + 0.5, 0, 1);
//Calculate white part
//fixed aWhite = 1;// smoothCircle(0.025, cGrad);
//aWhite -= smoothCircle(0.37, cGrad);
//aWhite += smoothBox(0.46, i.uv.xy);
//c = lerp(_BorderWhiteness, 0.8, aWhite);
//Add color
fixed aCol = smoothCircle(0.02, cGrad);
aCol -= smoothCircle(0.35, cGrad);
c = lerp(c, cWheel, aCol);
aCol = smoothBox(0.51, i.uv.xy);
c = lerp(c, cBox, aCol);
//Set alpha
fixed alpha = smoothCircle(0, cGrad);
alpha -= smoothCircle(0.4, cGrad);
alpha += smoothBox(0.49, i.uv.xy);
c.a = alpha;
return c;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9b76b6ef36124ee43b115ddf566992c5
timeCreated: 1429510240
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: