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.
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.
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?
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).
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.
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.
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:
using UnityEngine;
using System.Collections;
public class ScrollingGUIText : MonoBehaviour {
/* Public Variables */
// The array of GUIText elements to display and scroll
public GUIText[] textElements;
// The delay time before displaying the GUIText elements
public float displayTime = 5.0f;
// The delay time before starting the GUIText scroll
public float scrollTime = 5.0f;
// The scrolling speed
public float scrollSpeed = 0.2f;
// Update is called once per frame
void Update () {
// start display count down
displayTime -= Time.deltaTime;
if (displayTime < 0)
{
// if it is time to display, start the scrolling count down timer
scrollTime -= Time.deltaTime;
}
// if it is time to scroll, cycle through the GUIElements and
// increase their Y position by the desired speed
if (scrollTime < 0)
{
foreach (GUIText text in textElements)
{
text.transform.Translate(Vector3.up * scrollSpeed);
}
}
}
}