void Awake() { //setup initial variables state = GetComponent <StateManager>(); ci = new ModKey(KeyCode.None); keyCodeList = Enum.GetValues(typeof(KeyCode)) as KeyCode[]; gameModes = Enum.GetValues(typeof(StateManager.View)) as StateManager.View[]; //FISHING AROUND IN THE ASSEMBLY TO FIND ALL SUBCLASSES OF ACTIONTYPE actionTypes = from assembly in AppDomain.CurrentDomain.GetAssemblies() from type in assembly.GetTypes() where type.IsSubclassOf(typeof(ActionType)) select type; contexts = new ActionType[gameModes.Length][]; groups = new List <List <ActionType> > [gameModes.Length]; keyMap = new Dictionary <ModKey, List <ActionType> > [gameModes.Length]; keysToIgnore.Add(KeyCode.LeftShift); keysToIgnore.Add(KeyCode.RightShift); keysToIgnore.Add(KeyCode.LeftControl); keysToIgnore.Add(KeyCode.RightControl); keysToIgnore.Add(KeyCode.LeftAlt); keysToIgnore.Add(KeyCode.RightAlt); foreach (Type t in actionTypes) { //using Type to get public static field named "view" and cast it to StateManager.View StateManager.View v = (StateManager.View)t.GetField("view", BindingFlags.Public | BindingFlags.Static).GetValue(null); //Using Type to get pulic static field named "actions" and cast it to ActionType[] ActionType[] a = (ActionType[])t.GetField("actions", BindingFlags.Public | BindingFlags.Static).GetValue(null); //putting Array of ActionTypes into the context array at the position defined by View v contexts[(int)v] = a; //sorting the actionTypes into groups of paired actions groups[(int)v] = ActionType.GetActionGroups(a); //initialize the KeyMap of this GameMode to the default keys keyMap[(int)v] = new Dictionary <ModKey, List <ActionType> >(); defaultKeys(v); } //default to lobby if it found no action set for a particular context for (int i = 0; i < contexts.Length; ++i) { if (contexts[i] == null) { Debug.Log("WARNING: Input Manager did not find an action set for the StateManager View pointing to index: " + i); Debug.Log("Defaulting to lobby."); contexts[i] = contexts[(int)StateManager.View.Lobby]; groups[i] = ActionType.GetActionGroups(contexts[(int)StateManager.View.Lobby]); } } state.gui.CreateKeybindButtons(groups, gameModes); }