mob-sakai / SoftMaskForUGUI

Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
https://github.com/mob-sakai/SoftMaskForUGUI
MIT License
2k stars 262 forks source link

Update softmask not working when canvas component was deactivated #66

Closed Danilovic closed 4 years ago

Danilovic commented 4 years ago

Hi!

I have encountered an issue when I deactivate the canvas component of a gameobject where the masks are located, when softmask script tries to update those masks, it throws a null.

You can find a little package with an example.

SoftMaskIssue.zip

Regards

mob-sakai commented 4 years ago

Hi @Danilovic

Thank you for your reporting!

mob-sakai commented 4 years ago

@Danilovic

Many scripts are missing in your scene... X( Please zip your entire project folder and attach it.

image

Danilovic commented 4 years ago

@mob-sakai

I just downloaded the package in another pc with a clean Unity with no projects and I didn't see the missing files, in fact, I didn't use any custom script for this example. Could you show me the gameobject (s) with this problem?

mob-sakai commented 4 years ago

@Danilovic

I imported it to Unity2018.3 project on Mac. I will try again with a clean project. Thanks!

mob-sakai commented 4 years ago

@Danilovic

Hmm, I tested it with Unity2018.2 and Unity2018.3 on Mac and Windows, but it does not work... So, I fixed m_Script in scene file. I will test it later. :)

Softmask.unity.zip

Edit: All missing scripts are not solved...

mob-sakai commented 4 years ago

@Danilovic

Fix SoftMask.cs(line:428) as following:

if (!sm || sm._hasChanged)

To

if (!sm || sm._hasChanged || !sm.graphic || !sm.graphic.canvas)

Does it work well?

Danilovic commented 4 years ago

@mob-sakai

It doesn't work for me. I tested the package on Unity 2019.2.8 and works ok, without missing scripts so I tested the same package on Unity 2018.2 and I saw the missing files. Please check on Unity 2019.2.8

JJarvis89 commented 4 years ago

Hi, I am having the same issue.

Attached you can find a sample project (hopefully with no missing scripts!)

Steps:

  1. Open SampleScene
  2. Run
  3. Disable Canvas

This causes a NullReferenceException. Depending on which Canvas Render mode the culprit is either the Canvas or the Camera.

Kind regards SoftMaskIssue.zip

mob-sakai commented 4 years ago

@JJarvis89 , @Danilovic

Thank you! I will fix it ASAP.