I've been trying to get a GUI system to work using yield (which is, or at least should be, much easier than the alternatives), except that none of my code seems to be working. Come to think of it, I can see the problem with this approach (nothing would be displayed continuously without a loop or something to make it stay in place). Nevertheless, the odd part is that not a single line of code is working on any method that I call from OnGUI() that contains a yield statement, including debug code.
EG:
def OnGUI ():
Debug.Log("This works")
if GUILayout.Button("First button"):
Debug.Log("Pushed first button")
Test()
def Test ():
Debug.Log("But neither this")
if GUILayout.Button("Nor this"):
yield
GUILayout.Label("Nor this")
Debug.Log("Nor this works")
This has become.... quite frustrating.
I guess it will be back to the drawing board with xml and parsers if I can't get this scripting solution to work. (It's for a conversation system, btw. I thought, why bother with more arrays and data languages if I can get it to work just using scripts? Much simpler; more powerful... now this).
Yes, I'm well aware of that. But I'm using yield in a separate method (Test(), in the above example), so why isn't that working?
– anon75312049Ok, I can't get my code to run via boo, but I was able to get a bit of code running in javascript using yield within a loop. Not that that was what I had in mind, but yes, you actually can use yield in a method called by OnGUI - though it might just be due to a javascript bug... <sigh>. Back to the drawing board.
– anon75312049@Xathos: You need to use StartCoroutine in Boo if you want to start a coroutine. However, it's not what you want here, because the function would still be called every frame from OnGUI, so you'd end up with zillions of instances of it running.
– Eric5h5