Search Unity

Scrolling Credits. How?

Discussion in 'Immediate Mode GUI (IMGUI)' started by andy_h, Feb 22, 2010.

Thread Status:
Not open for further replies.
  1. andy_h

    andy_h

    Joined:
    Nov 3, 2009
    Posts:
    146
    Hi everyone,

    I'm trying to create a scrolling credits effect.
    I have a scene with a GUI Texture (set to scale 1,1,1)(X=0.5,Y=0.5,Z=0) which is the background picture and I wanted to have the credits scroll up over the top of this. I've been trying the GUI Text options and a few other things but nothing comes even close to what I have in my head.

    If anyone can help, I would appreciate it.
    Thanks
     
  2. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Hello Andy.

    I've found one easy way to do this is to have the credits as a texture on a plane. You then simply use Unity's built in animation editor to achieve the scrolling effect. Either by moving the camera over the plane, or the plane by the camera.
     
  3. andy_h

    andy_h

    Joined:
    Nov 3, 2009
    Posts:
    146
    I might be being a bit thick here so please bear with me.

    I just tried moving the GUI texture (the background picture) back to Z=1, then added a plane in front (Z=0, however when I ran it, it didn't show the plane.
    Camera is at Z=-10 facing the plane/GUI Texture.
    What did I do wrong?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If the credits are all in one GUIText object, just set the Y position so it's positioned off the bottom of the screen, and then do a loop with transform.Translate until it's scrolled off the top (or set transform.position directly).

    --Eric
     
  5. andy_h

    andy_h

    Joined:
    Nov 3, 2009
    Posts:
    146
    Hi Eric,

    Right I put the GUI Text just in front of the GUI Texture layer but now I'm only getting parts of the text coming through. It doesn't matter where I put the GUI Text on the Z axies just parts of the words come through.
     
  6. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Can you post the code you are using for this?
     
  7. andy_h

    andy_h

    Joined:
    Nov 3, 2009
    Posts:
    146
    Well, I finally got to see the text. (Had to restart unity).

    The code I am using is
    Code (csharp):
    1. var creditscroll: int;
    2.  
    3. function Update () {
    4.  
    5. if(Time.timeScale ==1.0) {
    6. Time.timeScale =0.002;}
    7.  
    8. Time.fixedDeltaTime = 0.002 * Time.timeScale;
    9.  
    10. transform.Translate(Vector3.up * Time.timeScale);
    11.  
    12. if(transform.position.y >= 1.80){
    13. Destroy(gameObject);
    14. }
    15. }
    So I parented each line of text to the one above, then use the script to move the main parent up.
    The only problem is that it works fine inside unity but when I build the project it shots past to quickly. It does seem to matter what I set it at, in the stand alone it flys by whilst inside unity it plays right.
     
  8. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You need to use Time.deltaTime. Time.timeScale is something completely different.
     
  9. andy_h

    andy_h

    Joined:
    Nov 3, 2009
    Posts:
    146
    Thanks Andeeee. Sorry for the delay. Didn't get a thread reply message.

    That's sorted it. Thanks to everyone that answered
     
  10. arbbot

    arbbot

    Joined:
    May 2, 2010
    Posts:
    74
    Hi guys,

    I wanted to share my approach. I created a script that takes an array of GUIText elements. The GUIElements are just GUIText objects parented with an empty object ("Credits") with position 0,0,0. Each GUIText object has the right start position (default position is x: 0.5, y: 0,5 and Z:0). Then you can have as many elements as you want and you can start with the first one at the center, and the others with a "-1.5" on the Y axis, so they are off the screen. The script has a start display timer and a start scrolling timer, and also the scrolling speed the GUIText will scroll.

    Here's the code of the script:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class ScrollingGUIText : MonoBehaviour {
    6.  
    7.     /* Public Variables    */
    8.    
    9.     // The array of GUIText elements to display and scroll
    10.     public GUIText[] textElements;
    11.    
    12.     // The delay time before displaying the GUIText elements
    13.     public float displayTime = 5.0f;
    14.    
    15.     // The delay time before starting the GUIText scroll
    16.     public float scrollTime = 5.0f;
    17.    
    18.     // The scrolling speed
    19.     public float scrollSpeed = 0.2f;
    20.    
    21.     // Update is called once per frame
    22.     void Update () {
    23.    
    24.         // start display count down
    25.         displayTime -= Time.deltaTime;
    26.        
    27.         if (displayTime < 0)
    28.         {
    29.             // if it is time to display, start the scrolling count down timer
    30.             scrollTime -= Time.deltaTime;
    31.         }
    32.            
    33.         // if it is time to scroll, cycle through the GUIElements and
    34.                 // increase their Y position by the desired speed
    35.         if (scrollTime < 0)
    36.         {
    37.             foreach (GUIText text in textElements)
    38.             {
    39.                 text.transform.Translate(Vector3.up * scrollSpeed);
    40.             }
    41.         }
    42.     }
    43. }
    44.  
    45.  
    Hope it helps.

    Cheers!
     
  11. leviMH

    leviMH

    Joined:
    May 30, 2010
    Posts:
    26
    See [link redacted by mod since it expired]
     
    Last edited by a moderator: Aug 8, 2023
  12. AtomicChimp

    AtomicChimp

    Joined:
    Aug 9, 2011
    Posts:
    47
    Nice! Thank you, leviMH!
     
  13. Immi

    Immi

    Joined:
    Jun 2, 2011
    Posts:
    81
    hello leviMH,
    Can you give me direct link of credit because i can't update unity 3.4.
    Thank you in advanced.
     
  14. darkforce

    darkforce

    Joined:
    Apr 5, 2012
    Posts:
    2
    var y : float = 500.0.;

    function Start () {

    }

    function Update () {
    y = y -1;
    OnGUI ();
    }
    function OnGUI () {

    GUI.Label(Rect((Screen.width/2)-40,y,200,50),"Directed By");
    GUI.Label(Rect((Screen.width/2)-40,y+20,200,50),"Børge Truelsen");
    }

    this works on my computer
     
  15. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    Why are you bumping a year old topic?
     
Thread Status:
Not open for further replies.