1
Support / Re: Question about depthmask and grayscale
« on: February 12, 2015, 03:44:51 am »
thank you very much . i fixed this problem .
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Shader "Sprites/GrayScale"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
_EffectAmount ("Effect Amount", Range (0, 1)) = 1.0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile DUMMY PIXELSNAP_ON
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half2 texcoord : TEXCOORD0;
};
fixed4 _Color;
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color;
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap (OUT.vertex);
#endif
return OUT;
}
sampler2D _MainTex;
uniform float _EffectAmount;
fixed4 frag(v2f IN) : COLOR
{
half4 texcol = tex2D (_MainTex, IN.texcoord);
texcol.rgb = lerp(texcol.rgb, dot(texcol.rgb, float3(0.3, 0.59, 0.11)), _EffectAmount);
texcol = texcol * IN.color;
return texcol;
}
ENDCG
}
}
Fallback "Sprites/Default"
}
void FixedUpdate()
{
this.transform.Translate(new Vector3(speed * Time.deltaTime, 0f, 0f));
}
void FixedUpdate()
{
if(this.transform.position != targetPoint)
{
this.transform.position = Vector3.SmoothDamp(this.transform.position, targetPoint, ref unused, 0.15f, float.MaxValue, Time.deltaTime);
}
}
but i dont see move smooth
public override void TouchDownOut (Vector2 position)
{
dragOrigin = new Vector3 (position.x, position.y, 0);
dragOrigin = camera.ScreenToWorldPoint(dragOrigin);
originTime = Time.time;
if(!isMove)
{
isMove = true;
}
}
public override void TouchMoveOut (Vector2 position)
{
Vector3 currentPos = new Vector3 (position.x, position.y, 0);
currentPos = camera.ScreenToWorldPoint(currentPos);
if(isMove)
{
if (Vector3.Distance(dragOrigin,currentPos) > 10f)
{
float amtToMove = 20f * Time.deltaTime;
LGController.state = LGController.State.Animation;
movePos = dragOrigin - currentPos;
movePos = new Vector3(movePos.x * amtToMove,movePos.y,movePos.z);
Vector3 newPos = transform.position + movePos;
newPos.y = this.transform.position.y;
transform.position = newPos;
}
}
}
public override void TouchUpOut (Vector2 position)
{
if(isMove)
{
isMove = false;
}
}
[AddComponentMenu("Lunge Mine/UI/UIWithDragScene")]
public class UIWithDragScene : tk2dUIBaseItemControl {
void Update()
{
if(uiItem.IsPressed)
{
if(LGController.state == LGController.State.Animation)
{
uiItem.Release();
}
}
}
}