Esempio n. 1
0
    public bool Load(ref List <JoystickControlScheme> joystickControls, ref List <KeyboardMouseControlScheme> keyboardControls)
    {
        var doc = CreateXmlDocument();

        if (doc == null)
        {
            return(false);
        }

        var root  = doc.DocumentElement;
        var nodes = SelectNodes(root, "ControlScheme");

        foreach (var node in nodes)
        {
            string type = ReadAttribute(node, "type", null);

            string            name   = ReadAttribute(node, "name", "Unnamed Control Scheme");
            string            id     = ReadAttribute(node, "id", null);
            ControlSchemeBase scheme = null;

            if (type == typeof(JoystickControlScheme).ToString())
            {
                scheme = joystickControls.Find(x => x.Name == name);
            }
            else if (type == typeof(KeyboardMouseControlScheme).ToString())
            {
                scheme = keyboardControls.Find(x => x.Name == name);
            }
            else
            {
                Debug.LogError("can't find type : " + type);
                continue;
            }

            scheme.DeserializeFromXml(node);
        }

        return(true);
    }
Esempio n. 2
0
 /// <summary>
 /// 将操作方案设回为默认值
 /// </summary>
 /// <param name="scheme"></param>
 public void ResetScheme(ControlSchemeBase scheme)
 {
     scheme.ResetToDefault();
 }