santijlm
santijlm
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
The code I l'm making is going to be executed every time a button in the UI is pressed, so everything I do is inside of an event handler. Any idea of what I could do?
20 replies
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
I read in SO that I could make a timer, similar to Unity's update, and detect if my key is pressed every 100ms. That's when I realised how big my problem is.
20 replies
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
I think I know why it does not work. The looping action includes a few System.Thread.Threading.Sleep. Probably that's why it doesn't get called.
20 replies
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
Lemme try it again
20 replies
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
I think I already tried this and didn't work
20 replies
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
20 replies
CC#
Created by santijlm on 1/3/2023 in #help
❔ Stop a loop when a key is pressed
I tried this: bool loop = true; while (loop) { //Loop Stuff if (IsKeyDown(myKey)) { loop = false; } } and this while (loop) { //Loop Stuff if (IsKeyDown(myKey)) { break; } } But they didn't work. Also, saw this in StackOverflow: while(!Console.KeyAvailable) { //do work } But apparently that won't work unless I use a Console Application. A few days ago I tried the code in this StackOverflow post, but I see it too complicated, and don't understand anything. ¿Could someone explain? I hate the idea of just pasting a piece of code I don't even understand.
20 replies
CC#
Created by wcasa on 1/3/2023 in #help
✅ Events and Delegates question..
with += and -= you can add more functions to the event itself, so that when it's invoked more functions are executed
123 replies
CC#
Created by wcasa on 1/3/2023 in #help
✅ Events and Delegates question..
And they can all change what happens when the event is invoked
123 replies
CC#
Created by wcasa on 1/3/2023 in #help
✅ Events and Delegates question..
You just call the event once and every sript can subscribe to it
123 replies
CC#
Created by wcasa on 1/3/2023 in #help
✅ Events and Delegates question..
The idea of a delegate is simple
123 replies
CC#
Created by santijlm on 9/14/2022 in #help
Read and Set a variable from another script in unity
then that's what i need
7 replies
CC#
Created by santijlm on 9/14/2022 in #help
Read and Set a variable from another script in unity
oh, sorry
7 replies
CC#
Created by santijlm on 9/14/2022 in #help
Read and Set a variable from another script in unity
but i think that could work
7 replies
CC#
Created by santijlm on 9/14/2022 in #help
Read and Set a variable from another script in unity
i mean a variable like a string
7 replies