|
Hi. I tried to convert javascript to C# with Networking sample. My code almost works, but some code doesn't work in NetworkLevelLoad.js (RPC function). I convert But at runtime, after first Thanks.
(comments are locked)
|
|
I'm currently struggling with the same task of converting the networking example to C# The problem is that yield containing functions must return an Enumerator but RPC functions must return void. The following code works for me.
(comments are locked)
|
|
this is one major mind fuck thanks to c# being nearly useless, and javascript being well, javascript. so i'm assuming we're all working off of the same code, and in order to fix the problem you need to make the following changes: so level additive works and i dont know exactly why, but you need to change your function to a non RPC with return type IEnumerator so that yield will work properly. and in order to call as a RPC, make a dummy function with return type void. and start a coroutine so yield can work its magic. What's the point in answering a 2 years old question with the same answer that is already there (Azzara) ? Btw you posted the answer two times. I deleted your second one since you had all your text bold and it's the same again ... Why do you complain about C#? Generator functions always work this way, even before Unity came out. I guess you just didn't used DontDestroyOnLoad on this gameobject, right? So if you load a new level this gameobject + script + coroutine is wiped out.
May 15 '12 at 08:18 PM
Bunny83
i dunno why it posted twice or in bold, but thanks for your answer. i probably didnt do that! just trying to adjust to this magical world of managed code. i'm used to having full control of how my program runs. my bad!?
May 26 '12 at 02:23 AM
kajjait
DontDestroyOnLoad ! I don't know that method until now! Very thanks.
Jul 05 '12 at 04:33 AM
Kichang Kim
And thanks for reply kajjait
Jul 05 '12 at 04:37 AM
Kichang Kim
(comments are locked)
|
|
Meantime, I dont have my debugger with me now but I'll convert it to something like this. Does it look similar to yours? thanks for reply. but "yield;" occured error in C#.
Nov 19 '10 at 07:51 AM
Kichang Kim
You cannot do coroutines like that in C#. You must return IEnumerator and the yield syntax is as follows "yield return 'value';" And, never "yield return 0;". There is an unnecessary memory allocation. Return null instead.
Feb 12 '11 at 02:21 PM
Peter G
Thanks Peter G
Jul 05 '12 at 04:38 AM
Kichang Kim
(comments are locked)
|

Are you getting any errors in your debugger?
no error. but MessageQueining after yield is not excuted.
I also want to know how to make yield work in RPC calls. It looks like they are not called if the return type of the RPC function is not
void.