Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class MoveManager:MonoBehaviour{
- Queue <Action> queue=new Queue<Action>();
- public void AddToQueue(Action act){
- queue.Enqueue(act);
- if(queue.Count==1){
- StartCoroutine(queueChecker());
- }
- }
- private IEnumerator queueChecker(){
- while(queue.Count!=0){
- yield return StartCoroutine(queue.Peek().ActionCor());
- queue.Dequeue();
- }
- }
- }
- public abstract class Action{
- public abstract IEnumerator ActionCor();
- }
- public class Move:Action{
- private int test;
- public Move(int _test){
- test=_test;
- }
- public override IEnumerator ActionCor(){
- yield return new WaitForSeconds(1);
- Debug.Log(test);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement