Skip to content

Instantly share code, notes, and snippets.

@shinriyo
Created January 25, 2014 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinriyo/8621249 to your computer and use it in GitHub Desktop.
Save shinriyo/8621249 to your computer and use it in GitHub Desktop.
C# Unity ナウローディング
using UnityEngine;
using System.Collections;
public class LoadingScript : MonoBehaviour
{
public string word = "NOW LOADING...";
public float height = 30.0f;
public float speed = 160.0f;
public float deltaX = 25.0f;
public float deltaTime = 30.0f;
public Vector3 wordSize = new Vector3 (28, 28, 1);
private int stringSize;
private bool isFinish = false;
private Transform[] labelArray;
void Awake ()
{
stringSize = word.Length;
labelArray = new Transform[stringSize];
for (int i=0; i<stringSize; i++) {
Transform trans = transform.Find ("OriginalLabel");
GameObject go = NGUITools.AddChild (gameObject, trans.gameObject);
go.name = i.ToString () + "Label";
go.transform.localScale = wordSize;
go.transform.localPosition = new Vector3 (i * deltaX, 0, -1);
UILabel uILabel = go.transform.GetComponent<UILabel> ();
uILabel.text = word.Substring (i, 1);
uILabel.depth = 1;
labelArray [i] = go.transform;
}
}
// Use this for initialization
IEnumerator Start ()
{
yield return new WaitForSeconds(3.0f);
isFinish = true;
}
// Update is called once per frame
void Update ()
{
float rad = Time.time * speed % 360;
for (int i=0; i<stringSize; i++) {
float yPos = Mathf.Sin ((rad - i * deltaTime) * Mathf.Deg2Rad) * height;
if (yPos < 0) {
yPos = 0;
}
labelArray [i].localPosition = new Vector3(labelArray [i].localPosition.x,yPos,-1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment