Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UI Particle System: advanced plugin for particles in GUI [RELEASED]

Discussion in 'Assets and Asset Store' started by MODev, Jan 26, 2018.

  1. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    It's optimized for mobiles too. Comparing to most of other solutions it's working faster.
     
    LilGames likes this.
  2. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Bug report: If I resize a UI Particle Depth Object in the editor at runtime, I get the following error.

    Code (CSharp):
    1. Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks, rendering callbacks or OnValidate. You must use Destroy instead.
    2. UnityEngine.Object:DestroyImmediate (UnityEngine.Object)
    3. UIParticleDepthObject:RefreshRenderer (bool,bool) (at Assets/Plugins/UIParticleSystem/Scripts/UIParticleDepthObject.cs:102)
    4. UIParticleDepthObject:CheckForRefeshRenderer () (at Assets/Plugins/UIParticleSystem/Scripts/UIParticleDepthObject.cs:90)
    5. UIParticleCanvas:OnCanvasCameraPreRender () (at Assets/Plugins/UIParticleSystem/Scripts/UIParticleCanvas.cs:223)
    6. UIParticleCanvas:OnCameraPreRender (UnityEngine.Camera) (at Assets/Plugins/UIParticleSystem/Scripts/UIParticleCanvas.cs:202)
    7. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    A similar problem occurs in a build when I drag the window from one monitor to another. The source of the error is different since it doesn't involve the Unity Editor's GUI, but it's similarly a problem with DestroyImmediate.

    Code (CSharp):
    1. Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks, rendering callbacks or OnValidate. You must use Destroy instead.
    2. UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
    3. UnityEngine.Object:DestroyImmediate (UnityEngine.Object) (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:318)
    4. UIParticleDepthObject:RefreshRenderer (bool,bool) (at C:/gamedev/unity/monospaced-lovers/Assets/Plugins/UIParticleSystem/Scripts/UIParticleDepthObject.cs:102)
    5. UIParticleDepthObject:CheckForRefeshRenderer () (at C:/gamedev/unity/monospaced-lovers/Assets/Plugins/UIParticleSystem/Scripts/UIParticleDepthObject.cs:90)
    6. UIParticleCanvas:OnCanvasCameraPreRender () (at C:/gamedev/unity/monospaced-lovers/Assets/Plugins/UIParticleSystem/Scripts/UIParticleCanvas.cs:223)
    7. UIParticleCanvas:OnCameraPreRender (UnityEngine.Camera) (at C:/gamedev/unity/monospaced-lovers/Assets/Plugins/UIParticleSystem/Scripts/UIParticleCanvas.cs:202)
    8. UnityEngine.Camera:FireOnPreRender (UnityEngine.Camera) (at C:/buildslave/unity/build/Runtime/Export/Camera/Camera.bindings.cs:436)
    This occurs with UI Particle System 1.34 and Unity 2020.3.14.
     
  3. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    Thank you for report, we will look into that soon and get back with fix to you
     
    _eternal likes this.
  4. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Thank you, please keep me posted.

    And while we're on the topic, I ran into another issue today. I believe the UI Particle Canvas's masks don't work correctly when the canvas camera's rect is changed? To test this, try the following:
    • Create a UI Particle Depth Object set to stretch (it should cover the whole canvas)
    • Create a UI Particle and set it to Use Clipping Mask (it should only render when inside the aforementioned depth object)
    • Change the main camera's and canvas camera's Viewport Rect to some arbitary value (eg x=0, y=0.05, w=1, h=0.9)
    • Create another camera and leave it with the default Viewport Rect
    It looks like the UI Particle Canvas's culling mask is taking into account some extra space at the top and bottom, so it's clipping too much. It's hard to explain, but here's a video:


    As you can tell, I ran into this problem when setting up letterboxing (that's why I was fiddling with the camera rects).
     
  5. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    520
    You're positive that the mask is 1:1 same area?
     
  6. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Yep, in fact here is a unity package to make things easier: https://drive.google.com/file/d/1Ogx7CW-raYfAEpCBEL8OScEkeEnxvi4F/view?usp=sharing

    That package doesn't include the UI Particle System asset itself, but it should work if you import the asset and add a layer to index 6.

    Granted, I might have made a mistake or gotten confused while testing this, so let me know if that's the case.
     
  7. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    @_eternal are you using URP or Standard pipeline? It has different approach for depth object and mask
     
  8. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    Soon (when Unity accept package) will appear 1.35 version with fixes of your "DestroyImmediate" error @_eternal . Resize windows we will check soon, you can try to call mask resize from UIParticleCanvas, maybe it will help when you change sizes of ViewportRect (tbh no one checked cutting viewport with dark bars here)
     
    Last edited: May 26, 2022
  9. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Great to hear, thanks for the quick fix. I'll take a look at Mask Resize. I'm using the Built-In Render Pipeline.
     
  10. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Update: as of 1.35, I'm still getting the DestroyImmediate error in a build when I drag the window to my second monitor. Not sure yet if it still occurs in the editor, because that error was somewhat inconsistent to begin with.

    Also, for what it's worth, I couldn't find anything resembling MaskResize inside of UIParticleCanvas. So I wasn't able to test that, but I think the sample project illustrates the problem pretty clearly.

    EDIT: Yep, DestroyImmediate error still occurs in editor when changing aspect ratio from 16:9 to 16:10.
     
    MODev likes this.
  11. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Actually, I think I was mistaken - the DestroyImmediate bug appears to be fixed now. But I think the aspect ratio bug is still present as per the sample project that I uploaded.
     
  12. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    Hi @_eternal thank you for your packege, this helped us find the solution. If you won't want to wait for asset store update just add at line 135 in UIParticleCanvas.cs in method Reinitialize this:
    Code (CSharp):
    1. maskCamera.rect = new Rect(0, 0, 1, 1);
    this should fix your issue.
    (if helped, good reviews for asset are always welcome :))
     
    Last edited: Jun 24, 2022
    _eternal likes this.
  13. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Hey, did this update ever get pushed to the asset store? I'm still seeing version 1.35 as the latest one.
     
  14. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    It should be, we will check what happened (sometimes asset stuck in unity asset review on holidays)
     
  15. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    1.36 released! You may notice there some issue fixes and improvements for unity 2020+
     
    _eternal likes this.
  16. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    263
    Nice! And yeah, I can confirm that the viewport rect problem is fixed now.
     
  17. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    Hello MoDev and thank you for the plugin.
    I'm struggling with a config.
    In my scene I have a perspective camera, a Screen Space - Camera canvas, a button, inside the button a mask, and inside the mask the particle system. I set up everything as you did in your example, the problem is that the image of the button is always above the particles. If I disable the image component of the button, the particles appear and are masked as intended.
     
    Last edited: Aug 30, 2022
  18. tomerbg2911

    tomerbg2911

    Joined:
    Apr 10, 2021
    Posts:
    1
    Hi.
    Great job with the asset. Does it also support TMP_Text? I noticed that UIParticleMaskSourceMode only support images.
    Thanks!
     
  19. DannyWoo

    DannyWoo

    Joined:
    Oct 25, 2012
    Posts:
    24
    Hello now i have an error as attached pic

    and also i want to know what is best way instantiate particle where mouse click position on canvas?

    thanks
    Dan
     

    Attached Files:

  20. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    @DannyWoo about your error: you should set different layer than your ui's (for example you can create UIParticleMask layer and set it there). Please check for tutorial video it's visible there that we set different value.

    About spawning particles: certainly it's not included in tool to support spawning particles (you should do it by yourself) so probably best is to ask on other forum thread. Only what I advice you here is to convert mouse position to canvas position and then to world space so you could just use Instantiate on your prefab.