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

i need code for (Glow button) help me please

Discussion in 'Scripting' started by simanama, Dec 31, 2011.

  1. simanama

    simanama

    Joined:
    Aug 25, 2011
    Posts:
    22
    hi all
    i want create a glow button see sample http://www.yourfilelink.com/get.php?fid=741366
    i have 2 image 1 image is normal(no glow button) and 1 image is gloweble button see sample



    now i want when mouse cursore is over gui texture or 3d plan morph image 1 to image 2 with (motion :ping pong) format and i need code (java) and i want know i change opacity of texture with scripting is better or change alpha of gui texture.
    so
    ineed code for cliked on the button
    thanks
     
  2. simanama

    simanama

    Joined:
    Aug 25, 2011
    Posts:
    22
    more help for glowbutton(attach file)
     

    Attached Files:

  3. _zeta

    _zeta

    Joined:
    Dec 24, 2011
    Posts:
    99
    just because of crapy sample video link i wont help you.
     
  4. Eiznek

    Eiznek

    Joined:
    Jun 9, 2011
    Posts:
    374
    Can simply use a gui style. And in the normal put the first and in hover add in your glow..

    Then its as simple as
    Code (csharp):
    1.  void onGUI()
    2. {
    3.     if(GUI.Button(new Rect(50,50,40,20), myGUIStyle)
    4.     // do something
    5. }
    6.  
     
  5. simanama

    simanama

    Joined:
    Aug 25, 2011
    Posts:
    22
    thanks
    so my buttons is a 3d object(plan) that code is for gui objects

    do you know how to change alpha value of a materials with script i want chang very slow.
     
  6. dart

    dart

    Joined:
    Jan 9, 2010
    Posts:
    211
    In C#
    Code (csharp):
    1.  
    2. Color c = myObject.renderer.material.color;
    3. c.a = 0.1F;  // Values between 0 and 1, 0 is completely transparent
    4. myObject.renderer.material.color = c;
    5.  
     
    Last edited: Jan 1, 2012
  7. simanama

    simanama

    Joined:
    Aug 25, 2011
    Posts:
    22
    thanks but i work with java script can you help?
    write this code with java script please
     
  8. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Code (csharp):
    1. var c : Color = myObject.renderer.material.color;
    2. c.a = 0.1F;  // Values between 0 and 1, 0 is completely transparent
    3. myObject.renderer.material.color = c;
    I think the difference between c# and javascript is trivial. (Set variable to color, change alpha, assign back to material.)
     
  9. simanama

    simanama

    Joined:
    Aug 25, 2011
    Posts:
    22
    thanks

    see this is final button i want morph image 1(gallery no glow) to image 2(gallery with glow) when mouse cursor is on the plan(button)
    so this is an animation button(only change(animate) image(texthure of image i think must i create 2 plan , plan 2 is copy of plan 1 and i put 2 image on the 2 plan .
    image 1 to plan 1 and image 2 to plan 2 so
    when alpha value of material 1 changed of 1 to 0 (with delay time) , the alpha value of material 2 changed of 0 to 1(with delay time)
    this animation of button is loop(ping pong) when mouse cursor is over button.
    so these is 2 image: $key 2.jpg $key 1.jpg

    see
    http://youtu.be/CWdki7YMQTU
    thanks to all lead
    this is link of button aniamtion http://www.youtube.com/watch?v=CWdki7YMQTU&feature=youtu.be
    ;)
     
    Last edited: Jan 2, 2012