Hi,
well I’m making a Input Manager… I’m on the GUI, and I want to set the values by clicking a button and saving the next movement…
So, I use Input.inputString, the problem is that when I click on anywhere, the inputString returns a null value, is there any other variables that returns the mouse values?
public static Dictionary<string, KeyCode> inputMap;
//Start()
inputMap = new Dictionary<string, KeyCode>();
tempInputMap.Add("Fire1", (KeyCode)System.Enum.Parse(typeof(KeyCode), "Mouse0")); //Charges those values with a for cicle extracted from a file
tempInputMap.Add("Fire2", (KeyCode)System.Enum.Parse(typeof(KeyCode), "Mouse0")); //Charges those values with a for cicle extracted from a file
tempInputMap.Add("Fire3", (KeyCode)System.Enum.Parse(typeof(KeyCode), "Mouse0")); //Charges those values with a for cicle extracted from a file
//OnGUI()
foreach(KeyValuePair<string, KeyCode> input in tempInputMap) {
string strInputValue = Enum.GetName(typeof(KeyCode), input.Value);
GUI.Label(new Rect(10, 50*i+5, 500-30-100-100, 40), input.Key, labelCentered);
if(GUI.Button(new Rect(500-20-100-100, 50*i+5, 100, 40), strInputValue) && !tempInputMap.ContainsValue(KeyCode.None)) {
tempInputMap[input.Key] = KeyCode.None;
} else if(tempInputMap.ContainsValue(KeyCode.None) && Input.anyKey) {
string[] SearchKeyByValue = tempInputMap.Where(x => x.Value == KeyCode.None).Select(pair => pair.Key).ToArray();
tempInputMap[SearchKeyByValue[0]] = (KeyCode)Enum.Parse(typeof(KeyCode), Input.inputString, true);
}
GUI.Button(new Rect(500-10-100, 50*i+5, 100, 40), "Reset");
i++;
}
Thanks in advance.
Bye.