Quantcast
Channel: Answers for "How to use yield within a class function"
Viewing all articles
Browse latest Browse all 4

Answer by avantius

$
0
0
I searched some more and found a solution for my issue. In case its of use to anyone else, here's the example code of what I found on the Unity forums: // Coroutiner.js // this class is just used to run coroutines and needs // no further functionality class Coroutiner extends MonoBehaviour { } // Test.js // a class inheriting from System.Object, using // coroutines: class Test extends System.Object { public static var coroutineRunner : Coroutiner = null; function Test() { if (coroutineRunner == null) { var go = new GameObject("Coroutiner"); coroutineRunner = go.AddComponent(Coroutiner); } } function Go() { coroutineRunner.StartCoroutine(MyCoroutine()); } function MyCoroutine() { yield; Debug.Log("it worked!"); } }

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>