Jumes
Topic Author
Posts: 16
Joined: 31 May 2017, 12:57

How to grey out whole control in Unity3d?

28 Aug 2017, 15:48

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?
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: How to grey out whole control in Unity3d?

30 Aug 2017, 12:49

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.
 
Jumes
Topic Author
Posts: 16
Joined: 31 May 2017, 12:57

Re: How to grey out whole control in Unity3d?

30 Aug 2017, 15:21

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.
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to grey out whole control in Unity3d?

30 Aug 2017, 17:22

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.
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: How to grey out whole control in Unity3d?

30 Aug 2017, 17:39

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.

Who is online

Users browsing this forum: No registered users and 1 guest