- Home /
How to prevent object disappearing when its pivot is transited out of camera's viewport
Hi, I'm trying to build game which has fixed "Main Camera", and "Background Sprite"-Almost twice of screen size, half alpha image. Background Sprite object should be transited by various game state.
My problem is occurred here, when background sprite is transited outside of camera's viewport, it is disappeared when its pivot(center of sprite) is out of viewport and because background sprite big, it still need to remain.
My first try was modifying its shader. Like below,
Shader "Unlit/UnlitAlphaNoCulling"
{
Properties
{
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white"
}
Category
{
Lighting Off
ZWrite On//it prevent sprite's disappearing
Cull Off
Tags {Queue=Transparent}
SubShader
{
Pass
{
SetTexture [_MainTex]
{
ConstantColor [_Color]
Combine Texture * constant
}
}
}
}
}
This simple shader prevent sprite's disappearing with "ZWrite On" But now this shader makes Jaggies which isn't exist in original sprite images.
Any advice will help me. Thanks
$$anonymous$$aybe you could switch off Frustrum Culling for the object. There appear to be hacks for $$anonymous$$esh-based objects, at least.