Page 1 of 1

How to grey out whole control in Unity3d?

Posted: 28 Aug 2017, 15:48
by Jumes
Hello,
I have a control which has a image brush background, some child image controls, and some other elements. I want ot grey out whole control when it is disabled.
After a quick searching, I found GrayScaleEffect is not supported. Is there a good way to do this?

Re: How to grey out whole control in Unity3d?

Posted: 30 Aug 2017, 12:49
by sfernandez
Hi,

You can just add a Border overlay inside your ControlTemplate that is only shown when control gets disabled:
<ControlTemplate TargetType="...">
  <Grid>
    ...
    <Border x:Name="DisabledOverlay" Background="#8888" Visibility="Collapsed"/>
  </Grid>
  <ControlTemplate.Triggers>
    <Trigger Property="IsEnabled" Value="False">
      <Setter TargetName="DisabledOverlay" Property="Visibility" Value="Visible"/>
    </Trigger>
  </ControlTemplate.Triggers>
</ControlTemplate>
It only needs to be on top of other elements of the control template.

Re: How to grey out whole control in Unity3d?

Posted: 30 Aug 2017, 15:21
by Jumes
I have not try the code above, I think it is not a graycale effect, the formula for converting RGB to gray is R*0.299 + G*0.587 + B*0.114.
So that will be fine if we can specify the alpha blend function for the overlay border.

Re: How to grey out whole control in Unity3d?

Posted: 30 Aug 2017, 17:22
by jsantos
We are working in the effects architecture that will allow you to achieve more flexibility for things like this. For now, there is now way to change the alpha blending function being used. We use the standard Over as in WPF.

Re: How to grey out whole control in Unity3d?

Posted: 30 Aug 2017, 17:39
by sfernandez
We don't have support for effects and alpha blending function cannot be customized in NoesisGUI.
That is why I suggested to simply use a semitransparent grey border as an alternative to get a disable look.