Function is not getting called for some reason?

In the below code, I have things set up to trigger screenshots based on different key inputs… I’m using KeyCode variables to store a key code. For example ScreenGrabToJPGKey1=KeyCode.J; I put Debug.Log(“here”); immediately inside each of the three functions. The PNG function gets called, the RAW function gets called, but the JPG function absolutely REFUSES to get executed. I know that the key works cus putting another Debug inside the IF shows that the key is getting pressed. Why would a function not get called? All three functions are static functions. No errors. I’m pulling my hair out trying to figure out why two of the functions work and one doesn’t. They’re even duplicates of each other, except for the name. Any ideaas?

				if (Input.GetKey(FrameworkGlobals.GrabScreenToPNGKey1) || Input.GetKey(FrameworkGlobals.GrabScreenToPNGKey2)) {
					//Save as PNG format to the desktop
					FrameworkScreenGrab.ScreenGrabPNG(true);
					}
				else if (Input.GetKey(FrameworkGlobals.GrabScreenToJPGKey1) || Input.GetKey(FrameworkGlobals.SGrabScreenToJPGKey2)) {
					//Save as JPEG format to the desktop
					Debug.Log("here");
					FrameworkScreenGrab.ScreenGrabJPEG(true);
				}
				else if (Input.GetKey(FrameworkGlobals.GrabScreenToRAWKey1) || Input.GetKey(FrameworkGlobals.GrabScreenToRAWKey2)) {
					//Save as RAW format to the desktop
					FrameworkScreenGrab.ScreenGrabRAW(true);
				}

Um, ok so in the other file I created 3 test functions, ie

static function Test1() {Debug.Log(1);}
static function Test2() {Debug.Log(2);}
static function Test3() {Debug.Log(3);}

And these functions all get called properly. So maybe it’s something strange in the structure of the functions that I have right now. Maybe I’m misusing some brackets or something. Grrr… I hope it’s something simple.

You are using KeyCodes but Input.GetKey require strings.

The documentation about keycodes is not as good as the rest…I can’t figure how to make it work. :?

No Input.GetKey can also use keycodes, there are two versions. That part is actually working fine for me.

I found that in my jpeg saving code, there is a line:

	while(!encoder.isDone)
		yield;

Which, when active (it waits because the jpeg encoder is multithreaded and needs to be finished), the yielding stops the previous Debug.Log (earlier in the function) from displaying. I presume this is something to do with timing, whereby the function in general gets executed faster than the display of the debug log update (maybe that updates in the next frame?), and thus does not show. The only way I could get it to show and to seemingly work is to change the line to WaitForSeconds(1) instead of yield.

Ok so the WaitForSeconds doesn’t really work without a yield statement, right? So I just do an infinite loop. Not huge biggie, at least on multicore systems.

But anyway… I noticed another function not getting called, for absolutely no apparent reason that I could narrow down.

Then it occurred to me, probably the Ctrl-J that I’m trying to detect is used by the editor? I noticed Ctrl-S doesn’t work either, which would make sense since it saves in the editor. Fortunately to my delight Ctrl-J (and S) can be properly detected in a real build.

Doh!

I (we ?) am (are) a little lost…

What I’m saying is it seems some key combinations don’t work when the game is running inside the editor… maybe because the editor is capturing them.