Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUI Text and Particles

Discussion in 'Editor & General Support' started by lgoss007, Dec 7, 2006.

  1. lgoss007

    lgoss007

    Joined:
    Dec 6, 2006
    Posts:
    88
    How can I attach, or rather keep a particle system with a GUI Text? Possible? I have it somewhat working, but I want the text to be able to scale with the resolution (so I took off Pixel Correct).
     
  2. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    A simple way would be to use a text mesh with a particle system child. As for a gui text there is a way to get the position of a point on the screen in 3d space but I have never really used it.

    Try searching the docs.
     
  3. lgoss007

    lgoss007

    Joined:
    Dec 6, 2006
    Posts:
    88
    Well I was looking at the docs, but the GetScreenRect was all I could find. And that gets the position in screen coordinates which I'd then somehow have to get the screen coordinates of the particle emitter to transform it to the correct position. But I think I thought of a better way from what you said.

    A text mesh doesn't seem to work on a GUI Text, but I found the 3D Text (which has a text mesh). I can use a script to keep the aspect ratio the same, so it will scale with the resolution like I want and the particle system will scale with it since it's a child. Only one problem...

    I can't find any docs on the 3D Text and my OnMouseEnter script isn't working.

    Code (csharp):
    1.  
    2. function OnMouseEnter () {
    3.     renderer.material.color = Color.white;
    4.     var effect = GetComponentInChildren(ParticleEmitter);
    5.     effect.emit = true;
    6. }
    7.  
    The same script worked in my GUI Text object, but not in my 3D Text. Also since I can't find the docs for 3D Text, I'm not sure how to change the color. I tried renderer.material.color but it doesn't seem to work. Almost seems like the OnMouseEnter isn't even being called.
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    The 3D Text docs are under TestMesh.
    For OnMouseEnter to work, you'll have to add a collider component.
     
  5. lgoss007

    lgoss007

    Joined:
    Dec 6, 2006
    Posts:
    88
    Ahh, thanks!