Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Michael Wigton · Jan 18, 2011 at 07:01 PM · textfadescrollanimated-text

Scroll intro text

Hey there!

I am having a problem with how to do the intro to my game, I am going to have the story displayed on screen by having the text scrolled from top to bottom and fade in and out(at top and bottom) hope that makes sense,

so what would be the best way to do this? I have tried using the fade.js script on the wiki but I could not get the desired result.

Thanks!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dr. damon · Nov 14, 2014 at 06:37 PM 0
Share

Create a 3D text in the Editor, this allows you to edits it position using the X, Y and Z axis. Now rotate the X-Axis by 45, then set alignment to "center".

Then create a script for the text, call it "TextIntro"(use Java) clear the script, then past this simple code:

 function FixedUpdate () {
     transform.localPosition.z += 1 * Time.deltaTime;
     transform.localPosition.y += 0.5 * Time.deltaTime;
 }

Hope this Benefits you.

5 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Flynn · Jan 18, 2011 at 07:29 PM

GUI.Label(new Rect(0,-1000 + (Time.time*100),Screen.width, 1000),"Some long text");

Where -1000 and 1000 are the height of your text, and 100 is how many pixels per second you want it to move down.

How it works:

Time.time steadily increases from the beginning of your game, in terms of seconds. Multiplying this buy 100 makes it faster, thus you can use it for scrolling effects.

IF the intro screen is NOT at the beginning of your game, then use this instead:

First, define a global float variable named off.

Then, run these two lines:

off += (Time.deltaTime*100);
GUI.Label(new Rect(0,-1000 + off,Screen.width, 1000),"Some long text");

Time.deltaTime if added each frame will add up to one by the end of the second. Likewise, this will behave exactly the same as the above code, except it always starts when your script loads rather than when your game loads. (If your script is pre-placed, it will load when the scene it is in loads. Otherwise, it loads when it gets added.)

Hope this helps -- Flynn

EDIT: Sorry, I did not catch the part about it fading in and out.

That's not really possible with GUI calls.

I'll get back to you on that in another answer.

EDIT:

There is one more way of doing it in the GUI: If you define each line in your intro as a separate item on an array, it could be done like so:

JS:

public var intro : String[];
public var off : float;
public var speed = 100;
function OnGUI()
{
    off += Time.deltaTime * speed;
    for (var i = 0; i < intro.Length; i++)
    {
        var roff = (intro.Length*-20) + (i*20 + off);
        var alph = Mathf.Sin((roff/Screen.height)*180*Mathf.Deg2Rad);
        GUI.color = new Color(1,1,1, alph);
        GUI.Label(new Rect(0,roff,Screen.width, 20),intro[i]);
        GUI.color = new Color(1,1,1,1);
    }
}

c#

using UnityEngine; using System.Collections;

public class ScrollerTest : MonoBehaviour { public string[] intro; public float off; public float speed = 100;

 public void OnGUI()
 {
     off += Time.deltaTime * speed;
     for (int i = 0; i &lt; intro.Length; i++)
     {
         float roff = (intro.Length*-20) + (i*20 + off);
         float alph = Mathf.Sin((roff/Screen.height)*180*Mathf.Deg2Rad);
         GUI.color = new Color(1,1,1, alph);
         GUI.Label(new Rect(0,roff,Screen.width, 20),intro[i]);
         GUI.color = new Color(1,1,1,1);
     }
 }

}

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Justin Warner · Jan 18, 2011 at 07:48 PM 1
Share

Use \n for line breaks in the Some long text, just adding. But great answer.

avatar image xfrog · Apr 27, 2011 at 12:58 AM 0
Share

hello Flynn, thanks for your code to autoscroll. it's works perfectly but I board not successful to reverse the direction. Could you help me, please

avatar image Lenn Dolling · Aug 23, 2011 at 01:27 PM 0
Share

for the reverse direction you would simply put a check to see where the current position is at... before the main draw for loop in the example..

if (mode == 1){ off += Time.deltaTime speed; } if (mode == 2){ off -= Time.deltaTime speed; }

//...loop code for

//...after flynn's draw code for block

if (roff > Screen.height) { mode = 2;}
if (roff < 0) { mode = 1;}

you probably have it all done by now though. just thought I would show you that it just takes a couple checks and a resetting of the check.. in my example above it just makes the text bounce up and down... very simple... gl

avatar image
1

Answer by Eric5h5 · Jan 18, 2011 at 07:48 PM

The easiest way to do the fade in/out effect is to have each line of text be separate, and make an array of text lines. Then you can have a routine that fades the lines based on distance from top/bottom, which is basically what the high score list for this does.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Justin Warner · Jan 18, 2011 at 07:25 PM

Have the text on a material and just have a script that moves the camera down. Gives the effect.

Use the translate/transform.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Flynn · Jan 18, 2011 at 07:34 PM

The other way of doing it is by scrolling the texture offset of a plane which has your text as it's image. You'll have to play with the settings on the material, but you can scroll the offset like this:

off += (Time.deltaTime/10); renderer.material.SetTextureOffset(off);

Then you can apply a shader which sets the alpha on top and on bottom as transparent.

I would not recommend this as such a shader would have to be custom built, and I am not a shader expert in the least.

Also rendering such a texture would be tough, and add allot of size to your project as the texture resolution would need to be enormous.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by spidarmen · Jun 22, 2012 at 10:05 AM

Is there a way to delay the GUI from scrolling until after it is loaded? When I load this in the webplayer, it is half way up the screen by the time the sceen is loaded. When I used yeild waitforseconds I get the error: OnGUI() cannot be a coroutine

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Making text appear from the bottom up 0 Answers

how to make text that is writen automatically, letter by letter 7 Answers

Changing text on Canvas Text is very slow / unresponsive 1 Answer

How to scroll a text through the trackpad of htc vive controller,How to scroll a text through trackpad of vive controller 0 Answers

How do i make my chat window save messages and be a scrolling GUI 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges