mob-sakai / UIEffect

UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
https://github.com/mob-sakai/UIEffect
MIT License
5.62k stars 773 forks source link

Different Material per Effect #175

Closed slacker-jake closed 5 years ago

slacker-jake commented 5 years ago

Hi,

I'm trying to use the effect to have a dissolve effect on my UI.Image component. This is working well except I would like to have two versions of the Image - one with ZTest set to false and another set to true (so when the object is occluded, you can see a faint version of the Image). However, when I try to use a different material/shader for the UIEffect it resets to the default. Is there a way around this?

Thanks, Jake

mob-sakai commented 5 years ago

Hi @jakeslack27 Thank you for using this plugin!

You want to use your custom material and shader on UIEffect component, right?

slacker-jake commented 5 years ago

Thank you for the fast response! That is right, I'd like to use a custom shader that has ZTest set to true so I can do overlay variety

mob-sakai commented 5 years ago

Oh, I see. Wait a minute!

mob-sakai commented 5 years ago

At the moment, UIEffect does not support it. In order to use a custom material, try following steps.

  1. Modify UIDissolve.cs to prevent the change of effectMaterial.
    protected override Material GetMaterial()
    {
    if (isTMPro)
    {
        return null;
    }
    return m_EffectMaterial; // ADD THIS LINE
    // return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_ColorMode); // REMOVE THIS LINE
    }
  2. Set custom material to Effect Material in inspector view (Debug mode.) image
  3. If you need, set material keyword ADD in inspector view (Debug mode) to use additional color mode.
mob-sakai commented 5 years ago

I will implement this feature in the near future. :)

slacker-jake commented 5 years ago

Hi,

I have tried following your instructions but unfortunately it doesn't seem to work for me. The initial change of the material works but as soon as I save the scene/apply prefab/play the scene my UI.Image component resets to the default material. Any additional step that could prevent that from happening?

Thanks, Jake

mob-sakai commented 5 years ago

Hi @jakeslack27 Ok, I will test it later.

slacker-jake commented 5 years ago

ありがといございます!

On Tue, 2 Jul 2019, 18:22 Takashi Sakai, notifications@github.com wrote:

Hi @jakeslack27 https://github.com/jakeslack27 Ok, I will test it later.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mob-sakai/UIEffect/issues/175?email_source=notifications&email_token=AE42HHJDKPYFOP5ZQSVZOVLP5MM43A5CNFSM4H4L5Z2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZAUVUY#issuecomment-507595475, or mute the thread https://github.com/notifications/unsubscribe-auth/AE42HHOFW27ATCYK5AR5KPLP5MM43ANCNFSM4H4L5Z2A .

slacker-jake commented 5 years ago

Hi Takashi san, any update on this!?

Thanks!

Jake Slack Software Developer

+44 203 865 3327 <020%203865%203327> ali@synertial.comwww.synertial.com http://www.synertial.com/www.mocapsuit.com http://www.synertial.com/UK: 57, Grange Road, Lewes, East Sussex, BN7 1TU, UK Taiwan: 4F, 266, SongJiang Rd. Taipei 10437, Taiwan, R.O.C

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

On Tue, Jul 2, 2019 at 6:23 PM Jake Slack jake.slack@synertial.com wrote:

ありがといございます!

On Tue, 2 Jul 2019, 18:22 Takashi Sakai, notifications@github.com wrote:

Hi @jakeslack27 https://github.com/jakeslack27 Ok, I will test it later.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mob-sakai/UIEffect/issues/175?email_source=notifications&email_token=AE42HHJDKPYFOP5ZQSVZOVLP5MM43A5CNFSM4H4L5Z2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZAUVUY#issuecomment-507595475, or mute the thread https://github.com/notifications/unsubscribe-auth/AE42HHOFW27ATCYK5AR5KPLP5MM43ANCNFSM4H4L5Z2A .

mob-sakai commented 5 years ago

Hi @jakeslack27 Sorry for my late reply.

That's strange. It seems like its working for me... Hmm, maybe you have set your material to Image.Material? image

If so it is wrong. Set your material to UIDissolve.EffectMaterial. image

slacker-jake commented 5 years ago

Sorry I'm a little confused.

When I set the material in UIDissove.EffectMaterial & the material in Image.Material to the correct material like so:

image

As soon as I hit Play or apply the prefab it resets to a hidden material I don't want to use:

image

What am I missing?

slacker-jake commented 5 years ago

Perhaps there is an easier way to achieve what I want to do? I simply want a small change in some of my UIDissolves to have their ZTest set to Always.

mob-sakai commented 5 years ago

OK @jakeslack27 There is a simple solution (with small changes) for that. It use shader keyword.

Just a moment please.

mob-sakai commented 5 years ago

Add code as following:

source.zip

slacker-jake commented 5 years ago

Awesome :)

Thank you so much for your help - I've managed to get the overlay working. However, there are two minor issues still remaing before I have the super, beautiful level of polish I'm looking for.

  1. The Compare Function doesn't seem to work on TextMeshPros so the overlay doesn't happen.
  2. The Color from the UI.Image doesn't seem to be filtering into the final material. I would like to show the overlay material at about 1/4 the opacity of the original but even with the alpha down it still shows full alpha.

OcclusionNone No occlusion

Occlusion With occlusion

mob-sakai commented 5 years ago

Oh, that's a beautiful scene. :) Just a moment please.

mob-sakai commented 5 years ago

Hmm, CanvasGroup.alpha does not affect UIEffect. It is a bug.

slacker-jake commented 5 years ago

ありがとうございます :)

Let me know if I can do anything to help? 私を手伝てくれてありがとう!

Jake Slack Software Developer

+44 203 865 3327 <020%203865%203327> ali@synertial.comwww.synertial.com http://www.synertial.com/www.mocapsuit.com http://www.synertial.com/UK: 57, Grange Road, Lewes, East Sussex, BN7 1TU, UK Taiwan: 4F, 266, SongJiang Rd. Taipei 10437, Taiwan, R.O.C

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

On Fri, Jul 12, 2019 at 9:22 AM Takashi Sakai notifications@github.com wrote:

Hmm, CanvasGroup.alpha does not affect UIEffect. It is a bug.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mob-sakai/UIEffect/issues/175?email_source=notifications&email_token=AE42HHOU2OIGSBGFLHKZKX3P67FCTA5CNFSM4H4L5Z2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZYKMUQ#issuecomment-510699090, or mute the thread https://github.com/notifications/unsubscribe-auth/AE42HHLUXI6IWRRWR3NQLOLP67FCTANCNFSM4H4L5Z2A .

mob-sakai commented 5 years ago

@jakeslack27 It seems to be working fine. :) (Z test always and transparent) Jul-12-2019 23-44-57

  1. Import the following unitypackage fix.unitypackage.zip
  2. Select the dissolve material for TextMeshPro in project view
  3. Set compare function to "Always" in material inspector view

If you need a material using another CompareFunction, duplicate the dissolve material and use it.

slacker-jake commented 5 years ago

6d3054ded19d3d0dc08d1e6ccfa62f7a

できた、よかった。ほんとにありがとうございます!

mob-sakai commented 5 years ago

I’m happy to hear that :smile::+1:

mob-sakai commented 5 years ago

This feature will be integrated in UIEffect v4.x :+1: