Shader on disabled object?

喜你入骨 提交于 2020-02-15 06:01:45

问题


Hi unity peoples I found this effect (disabled greyed out) while looking for something in the hierarchy panel I like it! - How would it be possible to add this kind of effect to game objects in game. are there any easy to implement solutions.

is it possible to use what unity is doing here in game? for example - on a locked item?

I'm not even sure what to search for. If this is a shader, or how this would be working.

void OnItemEnabled()
{
?
}

Some experiments so far Using a lit shader, it however loses details, and seems to need a way of pulling the colours out of the current shaders to maintain all the details

How I would like the monkey to look if locked

I made a grey scale shader... but it's a bit dark Not sure how to lighten it to match the look of "unity"

My final solution is here: Shader code is here, with slider-bar to adjust brightness :

Shader "Custom/GreyScale"
{
Properties
{
[PerRendererData] _MainTex("Base (RGB)", 2D) = "white" {}
_EffectAmount("Effect Amount", Range(0, 10)) = 1.0
}

SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200

CGPROGRAM
#pragma surface surf Lambert

uniform float _EffectAmount;
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};

void surf(Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = (c.r + c.g + c.b) / 3 * _EffectAmount;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
//Fallback "Transparent/VertexLit"
}

My solution here - code is above.

Swapping materials on unlock

Also I found this solution only solved half the problem, I had planned to swap shaders (but found this to be a no-no) so my solution for that is here Creating an unlockable game asset, writing a simple class

With thanks N

来源:https://stackoverflow.com/questions/60073798/shader-on-disabled-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!