示例#1
0
    // Currently only loads input from JSON file at /Resources/inputManager.json
    // TODO add check for custom input file, load from that if exists
    private bool loadListFromJson(string json, string platform)
    {
        JSONClass inputs = JSON.Parse(json) as JSONClass;

        if (inputs == null)
        {
            Debug.Log("input", "Json file is empty");
            return(false);
        }
        JSONClass cont = inputs["Keyboard"] as JSONClass;

        for (int i = 0; i < cont.Count; i++)
        {
            keyButtons.Add(cont.Key(i), cont[i].Value);
        }
        cont = inputs ["Controller"]["XboxOne"] as JSONClass;
        for (int i = 0; i < cont.Count; i++)
        {
            controllerButtons.Add(cont.Key(i), cont[i].Value);
        }

        return(true);
    }