       (reify IEnumerator
         (MoveNext [this]
           (when-not panic
-            (set! (.v cursor) (@current))
-            (if (.v cursor) true
-              (if (do (vreset! current (first @fns) )
-                      (vswap! fns rest) @current)
-                true
-                (!TimeLineCursor cursor)))))
+            (try 
+              (set! (.v cursor) (@current))
+              (if (.v cursor) true
+                (if (do (vreset! current (first @fns) )
+                        (vswap! fns rest) @current)
+                  true
+                  (!TimeLineCursor cursor)
+                  ))
+              (catch Exception e false))))
         (get_Current [this] (.v cursor))))
     (fn [] (if @current true false))))
 
-(defn lazier-timeline [fns]
-  (let [fns (map #(%) fns)
-        current (volatile! (first fns))
-        fns (volatile! (rest fns))
+(defn timeline-1 [fns] (timeline (map #(%) fns)))
+
+(defn array-timeline [^|System.Object[]| fns]
+  (let [cnt (long (dec (count fns)))
         ^MonoBehaviour coro-root (mono-obj)
         ^TimeLineCursor cursor (*TimeLineCursor 0 false 0.0)]
     (.StartCoroutine coro-root
       (reify IEnumerator
         (MoveNext [this]
-          (when-not panic
-            (try (set! (.v cursor) (@current))
-              (if (.v cursor) true
-                (if (do (vreset! current (first @fns))
-                        (vswap! fns rest) @current)
-                    true
-                  (!TimeLineCursor cursor)))
-              (catch Exception e false))))
+          (set! (.v cursor) 
+                (try (((aget fns (.i cursor))))
+                     (catch Exception e (log e))))
+          (if (.v cursor) true
+            (if (< (.i cursor) cnt) 
+                (set! (.i cursor) (inc (.i cursor)))
+                (!TimeLineCursor cursor))))
         (get_Current [this] (.v cursor))))
-    (fn [] (if @current true false))))
+    (fn [] false)))
+
+(defmacro timeline* [& fns]
+  (let [[opts fns] ((juxt (comp set filter) remove) keyword? fns)
+        ar (gensym)]
+    `(let [~ar (make-array ~'System.Object ~(count fns))] 
+      ~@(map-indexed #(list 'aset ar %1 (list 'fn [] %2)) fns)
+      (~'array-timeline ~ar))
+    ))
+
+(ppexpand 
+  (timeline* #(log "hello") 
+    (wait 0.5)
+
+
+     #(log "hello2")))
 
 
 

(def-pool 1000 WaitCursor start initiated)

(defn wait [n] 
  (let [cursor (*WaitCursor 0 false)] 
    (fn [] 
      (when-not (.initiated cursor) 
        (set! (.initiated cursor) true)
        (set! (.start cursor) Time/time))
      (if (pos? (- (+ (.start cursor) n) Time/time)) 
        true
        (!WaitCursor cursor)))))




(def run true)

(defn hue [^UnityEngine.Material m ^UnityEngine.GameObject o]
  (timeline-1
    (cycle [
      (fn [] (wait (+ (rand) 0.3)))
      (fn [] (tween {:material-color (UnityEngine.Color. (?f) (?f) (?f))} m 0.5 {:in :pow3}))
      (fn [] (tween 
        {:local {
          :scale (Vector3. 2.0 2.0 2.0)
          :position (v3+ (.position (.transform o)) 
                         (Vector3. 0.0 2.0 0.0))}} o 1.0 {:in :pow5}))
      ;(fn [] (wait (+ (rand) 0.1)))
      (fn [] (tween {:material-color (UnityEngine.Color. 1 1 1)} m 0.5 {:in :pow3})) 
      (fn [] (tween 
       {:local {
          :scale (Vector3. 1.0 1.0 1.0)
          :position (v3+ (.position (.transform o)) 
                        (Vector3. 0.0 0.0 0.0))}} o 0.5 :pow5))])))


(defn start-demo [_] 
  (clear-cloned!)
  (dorun (for [x (range 13) 
               z (range 13)
               :let [o (clone! :ball (V* (->v3 x 0 z) 2.0)) ]]
    (hue (.material (.GetComponent o UnityEngine.Renderer)) o))) )

'(timeline [
  (tween 
  {:light {
    :range (float (+ 15 (rand 50)))
    :color (color (rand-vec 1.0 1.0 1.0))}} 
