We will entertain your mind, enhance your brain, expand your lifestyle.

Gemini

We designed a class that associates game controller functions with key icons and changes the icons when key bindings are changed. We coded variables that correspond to keys and icons for each type of game controller (Xbox, PlayStation, etc.) and set them in the Inspector.

	[System.Serializable]
	public struct ButtonIDToIcon {
		public GamepadButtonID buttonID;
		public Sprite iconSprite;
	}
	[System.Serializable]
	public struct IconOfGamepadButton {
		public GamepadFamily gamepadFamily;
		public ButtonIDToIcon[] buttonIDToIcon;
	}
	[Header("Gamepad Key Image")]
	[SerializeField]
	public IconOfGamepadButton[] iconOfGamepadButtonDefine;

Defining a struct for the elements of the array is a last resort because the Dictionary type does not support the Inspector.

We set a value in the Inspector for an object that has this class as a component and started debugging, but for some reason a null exception occurred when accessing iconOfGamepadButtonDefine.

We investigated various options but couldn’t find the answer, so we attached the source code and asked Copilot what the error was. The answer was that there was an error in how Unity handled structs in the inspector, so we had to change it to a class. We followed the instructions and test it, but the error persisted.

So we asked Gemini3 the same question, and it replied that it was looking for a component other than the one configured in the Inspector. We investigated and found that an object created during the initial testing of this class was still there, but no values ​​had been set there.

It was a really basic mistake, but we wouldn’t have noticed it if it hadn’t been pointed out to us. This time it’s an article about Gemini’s victory.