blob: ed028a606ecddae0c19e502ecf21a764efa0610a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// To start a Coroutine directly, use "Start(SomeCoroutine());" in REPL mode.
// To declare a coroutine, you will need to compile it separately. For example:
public class MyCoro
{
public static IEnumerator Main()
{
while(true){
GameObject go = GameObject.Find("Player_Target");
if(go != null ) {
Rigidbody[] rigs = go.transform.GetComponentsInChildren<Rigidbody>();
for(int i = 0; i < rigs.Length; i++) {
var rig = rigs[i];
//Debug.Log(rig.gameObject.name);
Debug.DrawLine(rig.transform.position, rig.transform.position + 10*rig.transform.forward);
}
}
yield return null;
}
}
}
// To run this Coroutine in REPL, it would look like "Start(MyCoro.Main());"
Start(MyCoro.Main());
|