Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Soft Mask - A replacement of Unity UI Mask with alpha support

Discussion in 'Assets and Asset Store' started by zxkne, Feb 4, 2017.

  1. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hello @UnbridledGames,

    All right. You may have the following hierarchy:
    • MaskRectangle
    • Mask
      • MaskedElement1
      • MaskedElement2
      • ...
    Where MaskRectangle is just a RectTransform and Mask contains all the UI elements you want to mask. You may move MaskRectangle without affecting Mask or MaskedElements somehow.

    I've been reported that in some setups SoftMask may be CPU-expensive. It does some 'magic' to work autonomously without any effort on the user side. This means that it reacts to many Unity events such as OnRectTransformDimensionsChange or OnCanvasHierarchyChanged. If you don't touch the masked elements, it cost almost nothing on CPU. If you move the MaskRectangle, it recalculates mask coordinates and applies to the materials. Most expensive operations are adding and removing elements under the Mask root.

    If you decide to give it a try and will be unsatisfied with performance characteristics, I provide you a refund without any questions.

    Thank you for asking!
     
  2. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Good news, guys!

    Soft Mask 1.5 has just been released. The main feature of this update is Render Texture support. Now you can assign a Render Texture directly to a Soft Mask without a need to copy it to a temporary. You can watch it in action in the new example scene 06-RenderTexture. There also some improvements aimed at better compatibility with Unity 2019 and 2020.

    Here are full release notes:

    Improvements
    • Added support for Render Texture. Now it’s possible to assign a Render Texture to a Soft Mask via either Inspector or code.
    • Added a new example scene 06-RenderTexture that shows how to use Soft Mask with Render Textures.
    • Added support for Pixels per Unit Multiplier property of Sliced and Tiles Images. The same property is also available directly on Soft Mask in Sprite mode.
    • Added a menu command for easy conversion of a standard Mask into a Soft Mask.
    • Restructured TextMesh Pro-related examples. Now the root folder contains examples for the most relevant—package—version of TMPro.
    • Added support for the Softness parameter of Rect Mask in Unity 2020.1 or higher.
    Bug fixes
    • Fixed a bug due to which Update TextMesh Pro Integration menu might work incorrectly in some cases. It doesn’t rely on textual shaders names anymore.
     
  3. cow1787

    cow1787

    Joined:
    Aug 19, 2012
    Posts:
    13
    Does Preserve Aspect not work on a source Graphic Image for Soft Mask?

    My masked item is stretched because I want it to scale with the parent.
    My mask is set to stretch because I want the gameobject and its child to scale, but not the mask itself

    When checking "Preserve Aspect" on the mask's Image, the mask still seems to be stretched

    Below is a 'shine' overlay I want the angled bit to stretch as the banner gets larger. But because of its unique shape, I have to have an extra flap at the top left that I'd like to mask out.


    I apply a Soft Mask to the parent


    Checked "Preserve Aspect" on Image (also checked "Invert Mask" & "Invert Outsides" on Soft Mask)


    You can see it in the above image, but also below, that it's masking the entire thing as if the mask is still stretched. (There is a very faint line of where some of the blurred/aliased image comes through)


    Ideal result would look like this. Shine stays and stretched, but the top left flap is now masked
     
  4. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Unfortunately, the Preserve Aspect checkbox of the Image component is not supported yet. I'll check today's evening how difficult it would be to implement this and come back to you. Chances are that I'll be able to provide you a patch that adds support for Preserve Aspect.

    As an alternative approach, I also may suggest checking if Separate Mask may help here. Using this property you may detach the mask from the masked hierarchy, so it doesn't have to scale with the parent.
     
  5. cow1787

    cow1787

    Joined:
    Aug 19, 2012
    Posts:
    13
    Wow, okay yeah Separate Mask does work. (Sorry about that, I was certain I had tried that before posting!) Thank you
     
  6. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Great to hear!
    But anyway, as promised, here is an experimental patch that adds support for the Preserve Aspect option.
    All the changes are in the file SoftMask.cs. The first place to modify is method CalculateSpriteBased, you need to add the "if" block after "_parameter.maskRect = ...":
    Code (CSharp):
    1.     if (borderMode == BorderMode.Simple) {
    2.         var normalizedPadding = Mathr.Div(padding, sprite.rect.size);
    3.         _parameters.maskRect = Mathr.ApplyBorder(fullMaskRect, Mathr.Mul(normalizedPadding, Mathr.Size(fullMaskRect)));
    4.         if (isBasedOnGraphic && ((Image)_graphic).preserveAspect) {
    5.             _parameters.maskRect = PreserveSpriteAspectRatio(_parameters.maskRect, sprite.rect.size);
    6.         }
    7.     } else {
    And then right after this method add an another one:
    Code (CSharp):
    1.     Vector4 PreserveSpriteAspectRatio(Vector4 rect, Vector2 spriteSize) {
    2.         var spriteRatio = spriteSize.x / spriteSize.y;
    3.         var rectRatio = (rect.z - rect.x) / (rect.w - rect.y);
    4.         if (spriteRatio > rectRatio) {
    5.             var scale = rectRatio / spriteRatio;
    6.             return new Vector4(rect.x, rect.y * scale, rect.z, rect.w * scale);
    7.         } else {
    8.             var scale = spriteRatio / rectRatio;
    9.             return new Vector4(rect.x * scale, rect.y, rect.z * scale, rect.w);
    10.         }
    11.     }
    I also attached a patch in unified diff format, if that's more convenient for you.
    As I said, changes are experimental, I had no time to thoughtfully test them. And code is not of production quality, it definitely will be changed in the following update. But it still may be more elegant for your task than the Separate Mask facility.
    If you decide to use this code and encounter any issues, please let me know.
     

    Attached Files:

  7. mars_jang

    mars_jang

    Joined:
    Jul 1, 2020
    Posts:
    2
    I am very interested with this asset, seems great !
    Dose it work with URP camera stacking with mobile?
     
    Last edited: Jul 1, 2020
  8. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hi,
    Just checked it out: it does work. You may use a canvas in any mode (World Space, Camera, Overlay) and canvases from several cameras will be stacked together according to a camera stack. But I should warn you that Soft Mask works only with UI. If you're thinking on how to mask 3D objects rendered into a UI then you probably should use Render Texture, not stacked cameras (or maybe I just don't know how to use camera stack in such way).
     
  9. joe71731

    joe71731

    Joined:
    Jun 7, 2016
    Posts:
    2
    Hi:
    I use softmask in editor it looks wonderful,but when i play unity my softmask will hide everything it should show or hide,and it continue until i restart unity,but this is not everytime happen, sometimes it looks great,and next time i play it break again.

    i use soft mask for ngui ugui textmeshpro and i also use mask and rect mask 2d and ngui - UIpanel Texturmask
     
  10. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hi @joe71731
    First of all, I'm not sure, is NGUI compatible with standard Unity UI? Soft Mask works only with standard UI (based on CanvasRenderer component).
    There's also a known bug that may appear when you using Soft Mask together with standard Mask, more on this see in here.
    With the information, you provided it would be difficult for me to localize the issue. Could I ask you to either:
    • Prepare a minimal project that reproduces the issue
    • Tell more details on your scene setup: what's the scene hierarchy, how objects are nested into each other
    Thank you for reporting!
     
  11. joe71731

    joe71731

    Joined:
    Jun 7, 2016
    Posts:
    2
    HI
    I found reason i have some same shader and it looks like it may change material break, so i copy a new shader and material to distinguish, now it looks great
     
    zxkne likes this.
  12. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    835
    Hmm, is there still no tmpro support? Says shaders aren't supported
     
    Last edited: Aug 24, 2020
  13. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hi, TMPro support is here. To enable it you need to run the Tools / Soft Mask / Update TextMesh Pro Integration menu. It should generate shader variants which are compatible with Soft Mask. They'll be picked up automatically when a TMProText object goes under a Soft Mask.

    If that doesn't work, please, tell me which version of Unity and TextMesh Pro are you using. Are any errors pops up in Console when you run Update TextMesh Pro Integration? Also, keep in mind, that surface variants of shaders aren't supported.
     
    Noblauch likes this.
  14. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    200
    [Need Help – Custom Shader Compile Error]

    Hey, we just started using your soft mask, works great so far! I'm currently trying to convert our custom shaders with the help of your example. The implementation was straight forward, but it won't compile.

    When I add the include:
    #include "Assets/Imports/SoftMask/Shaders/SoftMask.cginc"


    Unity throws:
    Code (CSharp):
    1. Shader error in 'Whow/2DGlow': unrecognized identifier 'fixed4' at /Applications/Unity/Hub/Editor/2019.4.7f1/Unity.app/Contents/CGIncludes/UnityUI.cginc(10) (on metal)
    2.  
    3. Compiling Vertex program
    4. Platform defines: UNITY_NO_DXT5nm UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_DLDR_ENCODING
    which corresponds to this function:
    Code (CSharp):
    1. inline fixed4 UnityGetUIDiffuseColor(in float2 position, in sampler2D mainTexture, in sampler2D alphaTexture, fixed4 textureSampleAdd)
    2. {
    3.     return fixed4(tex2D(mainTexture, position).rgb + textureSampleAdd.rgb, tex2D(alphaTexture, position).r + textureSampleAdd.a);
    4. }
    Hope you have a suggestion how to fix it, the whole shader code is extremely long, because its generated through shader graph, we don't have a real graphics programmer in our team, that's why I'm trying to figure all that out :p
     
  15. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hi, @Noblauch

    Could you try to #include "UnityCG.cginc" before including "SoftMask.cginc"? It seems like standard Unity macros aren't defined. "SoftMask.cginc" probably should do this by its own and it should not rely on the outer code. I'll make a note for a future version.

    If that will not help, could I see full source code of the shader that doesn't compile? You may send me it on email if you don't want to publish it here.
     
  16. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    200
    Hey, thanks for your quick response ;)

    I tried adding #include "UnityCG.cginc" before SoftMask, and it yielded a new error:
    Shader error in 'Whow/2DGlow': redefinition of '_Time' at /Applications/Unity/Hub/Editor/2019.4.7f1/Unity.app/Contents/CGIncludes/UnityShaderVariables.cginc(40) (on metal)


    This is because UnityCG.cginc is not a default library for shader-graph shaders, and it wasn't inside my shader code before.

    I also made sure to #include your .cginc at the very end, but I get the same error.
    You can just reproduce it with an empty shader-graph, here is one with #include "SoftMask.cginc" already added and uncommented in line 67:
    https://pastebin.com/EKpwps8d

    I guess this plugin was just never tested with shader graph generated code?
     
    Last edited: Sep 4, 2020
  17. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Ouch, I missed the point that you're using Shader Graph, sorry :)

    Unfortunately, when I last time checked it out from an integration view point, I come to conclusion that it's not possible to effectively use Soft Mask with Shader Graph. You may find my thoughts on this topic in this post. While it's possible in theory, I'm not ready to support it right now. If you wanted to use Soft Mask exclusively with Shader Graph, sorry for this. I may provide a refund if you send me your invoice number in PM.
     
  18. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    200
    Ouch, if you want to stay competitive with the currently developed games, you should really get into it! I see the struggle that comes with it, but maybe there is some kind of hack that can be implemented to get the desired information inside the graphs output.
    I mean, in the end the graph generates normal shader code.

    We'll probably keep the asset and see if we can outsource the shader development for our few custom shaders to work with SoftMask, but I'll need to talk to my team for a final decision ;)

    Still, thanks for the fast support and the option for refund, great asset in general!
    A demonstration of poverty that Unity doesn't provide basic functionality like this and people like you need to tackle this :s
     
    zxkne likes this.
  19. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    200
    SoftMask not respecting Maskable flag?
    We are just facing another problem: SoftMask doesn't seem to care if the Maskable flag in the image component is set or not. There are quite some scenarios where this is needed, one at the moment is a scrollview with content that has a delete popup above it. This of course has to always be on top, and can not be cut away from the viewport.

    Is there a recommended workaround for that?
     
  20. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    You may try to replace the SoftMaskable.isMaskingEnabled property in file SoftMaskable.cs, line 20 with the following:
    Code (CSharp):
    1.         public bool isMaskingEnabled {
    2.             get {
    3.                 return mask != null
    4.                     && mask.isAlive
    5.                     && mask.isMaskingEnabled
    6.                     && _affectedByMask
    7.                     && isGraphicMaskable;
    8.             }
    9.         }
    10.  
    11.         bool isGraphicMaskable {
    12.             get {
    13.                 if (!graphic)
    14.                     return false;
    15.                 var maskableGraphic = graphic as MaskableGraphic;
    16.                 if (!maskableGraphic)
    17.                     return true;
    18.                 return maskableGraphic.maskable;
    19.             }
    20.         }
    I've tested it and it seems to work as expected.
    I'll include proper support for Maskable flag to the next patch.
    Thank you for reporting! If this solution will not work, please, let me know.
     
    justtime and Noblauch like this.
  21. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    200
    Yes it does indeed work, thank you!
     
    zxkne likes this.
  22. LeventP

    LeventP

    Joined:
    Jul 17, 2020
    Posts:
    15
    Hey, I have an issue when I try to use softmask in a certain way. Using version 1.5

    The object hiearchy is like this:

    MaskObject (Unity Mask)
    -> Scroll Rect
    -> Viewport (With SoftMask)
    -> Content
    -> Item
    -> TextMeshProText​

    The TextMeshProText uses multiple fonts in a single line, so it uses a TMP SubMeshUI that it generates on runtime. When running, the name of the shader that the TMP SubMeshUI uses becomes "SoftMask/TextMeshPro/Distance Field Masking ID: 1" and part of the text becomes invisible.

    If then I move the TMP text out of the SoftMask by changing its parent, and move back under the Item object, "Masking ID: 1" gets removed from the shader name and the text becomes wholly visible again.

    Is this a bug? Is there a way to work around this problem?
     
    Last edited: Sep 24, 2020
  23. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    I reproduced the issue. Now I need some time to figure out what's going on. I'll come back soon. Thank you for reporting!
     
  24. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    @LeventP,
    After some investigation I finally found out what's happening.

    When TMPro spawns child SubMeshUI objects, it firstly spawns an empty object and then add required components to it. SoftMask 'intercepts' creation of a new object and adds an invisible SoftMaskable component (all masked objects under a SoftMask have these components). Thus, SoftMaskable component appears above SubMeshUI in the components stack. And here a known Unity peculiarity comes into play: MaskableGraphic (a base class of SubMechUI) doesn't respect IMaterialModifiers that stay before it in the components stack, it just drops any changes made to material by any of these modifiers. I wrote about this issue in this post. Unity doesn't plan to fix this, which is understandable: I guess they suppose that MaskableGraphic should always stay above any modifiers.

    We can work around this issue, of course. But the best approach depends on whether you want this to work in play mode or in editor.
    1. In Editor it's possible to rearrange objects manually as you described. This process may be simplified by, say, adding a 'Force Reset' button to SoftMask Inspector.
    2. In the play mode you need to destroy the SoftMaskable component on the SubMeshUI object and then re-create it by calling SoftMask.UpdateTransformChildren(x) where x is the parent transform of SubMeshUI. This may have some performance impact, so I would not recommend to do it if it's possible to fix the issue in edit mode.
    I can help you with either of these options, just let me know which variant you're interested in.
     
  25. LeventP

    LeventP

    Joined:
    Jul 17, 2020
    Posts:
    15
    Thanks for the investigation and detailed explanation!

    The Editor fix makes it work while I am still in the Editor, but the fix gets reverted when the game is actually being played. So that doesn't work for me.

    Although the performance impact is not ideal, I guess I need to go with the second option

    P.S. The ability to use nested SoftMasks is something that I really desire. Do you have any plans to integrate that?
     
  26. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    You right, I missed the point that spawned SubMesh objects are transient, that is, they're destroyed and re-created each time a scene loads. So yes, we need to fix this at play time.

    Good news is that I found an elegant workaround that doesn't cost any performance. It doesn't solve problem in the large (SoftMaskable should never stay above MaskableGraphic in the component list) but it work pretty well for your case with multi-font texts.

    I'm attaching a .patch file in unified diff format (renamed to .txt due to forum limitations). It contains all the required changes. If you do not know how to deal with it, do not worry, I also sent you SoftMask.cs file in PM, so you may just replace entire file.

    Please, let me know if it helped or not.

    UPDATE I deleted the attachment because it didn't work properly. Fixed version of it may be found here.
     
    Last edited: Sep 28, 2020
  27. LeventP

    LeventP

    Joined:
    Jul 17, 2020
    Posts:
    15
    Thanks for the quick help. I didn't know what to do with the .patch file so I used the .cs.
    This helped in the sense that the text is no longer invisible, however, the text is also no longer masked, at all :p
     
  28. AytoMaximo

    AytoMaximo

    Joined:
    Aug 26, 2015
    Posts:
    49
    Hello! I'm using a transparent sprite as a mask, but for some reason it makes its filling child transparent too. Any way to fix this? Thx!

    Снимок экрана 2020-09-26 в 17.08.27.png Снимок экрана 2020-09-26 в 17.11.50.png Снимок экрана 2020-09-26 в 17.12.57.png
     
  29. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    That's strange. I just checked it again on a fresh project and it worked for me. Did't you forget to run Tools / Soft Mask / Update TextMesh Pro Integration menu? If not, need to ask you some further questions to diagnose the issue:
    1. Which versions of Unity and TextMesh Pro are you using?
    2. Can you reproduce the issue by using just standard TMPro fonts and some built-in image as a mask? If yes, could you send me an example project that reproduces it in PM?
     
  30. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    I'm not sure that I got you right, but making children transparent is the whole purpose of Soft Mask :) The resulted color of a pixel of the child object is multiplied by mask alpha value, it's intended. In your case you probably should use separate sprites for parent's image and mask (you may specify sprite directly to a Soft Mask). The second image should be fully opaque in places where you want the children be fully opaque.
     
  31. LeventP

    LeventP

    Joined:
    Jul 17, 2020
    Posts:
    15
    I had ran the menu command, just to make sure, I ran it again now and it's still the same.

    I'm on Unity 2019.3.0f3 with TextMeshPro v 2.1.0 (preview.14). I'll try to reproduce it in an example project. I'm on vacation next week so I'll probably be able to get on that when I come back
     
  32. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Thank you for answers, I'll try to reproduce with this setup.

    Two more thinks came to my mind that may bring the light on the issue:
    1. Do not you use any surface materials? Soft Mask doesn't work with TMPro's surface (3D) materials.
    2. Do any warnings or errors appear in the console?
     
  33. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    @LeventP,
    I've found a bug in the previous solution. I'm attaching a fixed patch (which may be useful for someone else) and also sending you SoftMask.cs in PM.

    UPDATE A bug was found in this version of a workaround, so I removed the attached file. See this post for the actual version.
     
    Last edited: Oct 11, 2020
  34. LeventP

    LeventP

    Joined:
    Jul 17, 2020
    Posts:
    15
    Hey @zxkne,
    Thanks for the help, I just tried the .cs out. It seems to have fixed my issue completely. But while testing it out I may have come across another bug that might be caused by the changes. I'm attaching an image that shows it, and the console log is below. As for your two questions, I use no surface materials, and I received no warnings or errors.

    MissingReferenceException: The object of type 'RectTransform' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    SoftMasking.SoftMask.SpawnMaskablesInChildren (UnityEngine.Transform root) (at Assets/3rd Party/SoftMask/Scripts/SoftMask.cs:566)
    SoftMasking.SoftMask.OnWillRenderCanvases () (at Assets/3rd Party/SoftMask/Scripts/SoftMask.cs:487)
    UnityEngine.Canvas.SendWillRenderCanvases () (at <10736a79335545708e4e332fcf58a2b7>:0)
     

    Attached Files:

  35. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    For anyone who may be interested in a yet-experimental workaround of multipoint TMPro issue, here is an updated version of the patch. The previous version contained a null-reference access bug described in the previous post.
     

    Attached Files:

  36. JohnnyQuest1983

    JohnnyQuest1983

    Joined:
    Mar 24, 2020
    Posts:
    1
    Hello

    Is there any chance that using Text (or TMPro) as the masking object would be supported in Soft Mask? Currently it seems to use the Rect Transform of the Game Object that the Text is on.

    Unity's default Mask option supports using Text (although not TMPro, I think), but as with all of Unity's built in masking it looks really bad on the curves (and there are a lot of curves in fonts).
     
  37. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hello,

    It could be done in theory by drawing text (or any other Graphic object) to a Render Texture and then using this Render Texture as a mask. I did some research in this direction some time ago, but I do not have any specific plans on this subject right now. If you're considering buying Soft Mask in hope that it will support this functionality in the near future, I'd not recommend doing it.

    What's about standard Unity's mask, it should work with TextMesh Pro text too as it relies on picture that's actually being drawn (i.e. supports any Graphic object).
     
  38. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,045
    Hi.

    I have imported the package and I get these errors :

    Assets\SoftMask\Scripts\MaterialReplacer.cs(25,6): error CS0641: Attribute 'AttributeUsage' is only valid on classes derived from System.Attribute

    Assets\SoftMask\Scripts\TextMeshPro\MaterialReplacer.cs(4,6): error CS0616: 'GlobalMaterialReplacerAttribute' is not an attribute class


    Any idea? I do have TextmeshPro package installed with essential resources.

    Unity 2020.2 beta11
    Using TMP version 3.03
     
  39. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hi,

    It's very strange issue, because GlobalMaterialReplacerAttribute class is actually derived from System.Attribute. Could you try to reimport Soft Mask scripts? Right click on SoftMask/Scripts in Project window and select Reimport.

    If that will not help, then try to completely delete SoftMask folder and re-import it from Package manager (if you haven't modified it). If even this do not help, please, let me know.
     
  40. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,045
    I have tried to reinstall it, but the same error happens.
     
  41. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,045
  42. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,045
    I have fixed the issue by adding System name space for Attribute. Apparently, I had another class named Attributes.
    I think this kind of case can happen, so adding System explicitly will help. So it will be a good idea to add that for the future update.
     
    zxkne likes this.
  43. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Great to hear! And thank you for advice. Another possible solution is to compile Soft Mask into a separate assembly by using assembly definition files. I haven't introduced it yet because I also support old versions of Unity which do not have this feature. Anyway, I'll take that into consideration in future versions.
     
    castor76 likes this.
  44. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,045
    Hi. Also, the shader include code bit is absolute path so it is better to make them like

    #include "../../SoftMask.cginc" // Soft Mask

    so that moving asset into different folder can still work.
     
    zxkne likes this.
  45. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    I agree, it would be nice. But I still have to use absolute paths for TMPro includes. Absolute paths are used only in generated shaders, so it's easy to fix them by re-generating via Tools / Soft Mask / Update TextMesh Pro Integration menu. Thank you for the feedback!
     
  46. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,045
    Yeah normally TMP path does not change, but I like the 3rd party asset goes into StandardAsset folder or others because I don't like cluttering the root with many 3rd party asset folders. This is very common practice among developers. So it's not perfect, but it does cover a lot of cases.
     
    zxkne likes this.
  47. brummer

    brummer

    Joined:
    Jul 3, 2013
    Posts:
    13
    Is it possible to implement a masking solution that doesn't require hierarchy, but instead "targets" to mask?
    I want to move/rotate/scale masks without affecting the underlying object WITHOUT code.
     
  48. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    Hi, sorry for such a long delay, I missed your post. Unity forum sometimes just doesn't send notifications :(

    Answering your question, with Soft Mask you can separate UI hierarchy from the object that defines mask shape. You still have to have a masking root—object with a Soft Mask script attached. But you can specify another unrelated transform in Soft Mask's Separate Mask property. That transform will define shape of a mask.
     
  49. LukeDawn

    LukeDawn

    Joined:
    Nov 10, 2016
    Posts:
    375
    Just purchased, and want to say thank you. Written a 5 star review as well. Simplest asset to use ever.
     
    zxkne likes this.
  50. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    183
    How nice to hear those words! Thank you for getting time to write a review.
     
unityunity