Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class FlashCRTest : MonoBehaviour {
- List<string> a = new List<string>(new string[] { "thing 1", "thing 2", "thing 3" });
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown (KeyCode.Alpha1))
- {
- StartCoroutine(CR1());
- }
- if (Input.GetKeyDown (KeyCode.Alpha2))
- {
- StartCoroutine(CR2());
- }
- }
- IEnumerator CR1() {
- // Does not work in flash
- float startTime = Time.time;
- while (Time.time < startTime+1) {
- transform.Translate(Vector3.up * Time.deltaTime);
- yield return null;
- }
- foreach (string s in a)
- {
- Debug.Log (s);
- yield return null;
- }
- }
- IEnumerator CR2() {
- // Works in flash
- float startTime = Time.time;
- while (Time.time < startTime+1) {
- transform.Translate(Vector3.up * Time.deltaTime);
- yield return null;
- }
- for (int n=0; n<a.Count; ++n)
- {
- string s = a[n];
- Debug.Log (s);
- yield return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment