public void ResetInputs()
        {
            InputConfiguration inputConfig    = InputManager.GetInputConfiguration(m_inputConfigName);
            InputConfiguration defInputConfig = null;

            using (StringReader reader = new StringReader(m_defaultInputs.text))
            {
                InputLoaderXML loader = new InputLoaderXML(reader);
                defInputConfig = loader.LoadSelective(m_inputConfigName);
            }

            if (defInputConfig != null)
            {
                if (defInputConfig.axes.Count == inputConfig.axes.Count)
                {
                    for (int i = 0; i < defInputConfig.axes.Count; i++)
                    {
                        inputConfig.axes[i].Copy(defInputConfig.axes[i]);
                    }
                    InputManager.SetConfigurationDirty(m_inputConfigName);
                }
                else
                {
                    Debug.LogError("Current and default input configurations don't have the same number of axes");
                }
            }
            else
            {
                Debug.LogError(string.Format(@"Default input profile doesn't contain an input configuration named '{0}'", m_inputConfigName));
            }
        }
예제 #2
0
        public void ResetInputs()
        {
            ControlScheme controlScheme    = InputManager.GetControlScheme(m_controlSchemeName);
            ControlScheme defControlScheme = null;

            using (StringReader reader = new StringReader(m_defaultInputProfile.text))
            {
                InputLoaderXML loader = new InputLoaderXML(reader);
                defControlScheme = loader.Load(m_controlSchemeName);
            }

            if (defControlScheme != null)
            {
                if (defControlScheme.Actions.Count == controlScheme.Actions.Count)
                {
                    for (int i = 0; i < defControlScheme.Actions.Count; i++)
                    {
                        controlScheme.Actions[i].Copy(defControlScheme.Actions[i]);
                    }

                    InputManager.Reinitialize();
                }
                else
                {
                    Debug.LogError("Current and default control scheme don't have the same number of actions");
                }
            }
            else
            {
                Debug.LogErrorFormat("Default input profile doesn't contain a control scheme named '{0}'", m_controlSchemeName);
            }
        }
		public void ResetInputs()
		{
			InputConfiguration inputConfig = InputManager.GetInputConfiguration(m_inputConfigName);
			InputConfiguration defInputConfig = null;

			using(StringReader reader = new StringReader(m_defaultInputs.text))
			{
				InputLoaderXML loader = new InputLoaderXML(reader);
				defInputConfig = loader.LoadSelective(m_inputConfigName);
			}

			if(defInputConfig != null)
			{
				if(defInputConfig.axes.Count == inputConfig.axes.Count)
				{
					for(int i = 0; i < defInputConfig.axes.Count; i++)
					{
						inputConfig.axes[i].Copy(defInputConfig.axes[i]);
					}
					InputManager.SetConfigurationDirty(m_inputConfigName);
				}
				else
				{
					Debug.LogError("Current and default input configurations don't have the same number of axes");
				}
			}
			else
			{
				Debug.LogError(string.Format(@"Default input profile doesn't contain an input configuration named '{0}'", m_inputConfigName));
			}
		}
예제 #4
0
        private void LoadInputConfigurationsFromResource(string resourcePath)
        {
            if (_inputManager.inputConfigurations.Count > 0)
            {
                bool cont = EditorUtility.DisplayDialog("Warning", "This operation will replace the current input configrations!\nDo you want to continue?", "Yes", "No");
                if (!cont)
                {
                    return;
                }
            }

            TextAsset textAsset = Resources.Load <TextAsset>(resourcePath);

            if (textAsset != null)
            {
                using (System.IO.StringReader reader = new System.IO.StringReader(textAsset.text))
                {
                    InputLoaderXML inputLoader = new InputLoaderXML(reader);
                    _inputManager.Load(inputLoader.Load());
                    _selectionPath.Clear();
                }
            }
            else
            {
                EditorUtility.DisplayDialog("Error", "Failed to load input configurations. The resource file might have been deleted or renamed.", "OK");
            }
        }
예제 #5
0
        private void ConfigureForInputAdapter()
        {
            if (_inputManager.inputConfigurations.Count > 0)
            {
                bool cont = EditorUtility.DisplayDialog("Warning", "This operation will replace the current input configrations!\nDo you want to continue?", "Yes", "No");
                if (!cont)
                {
                    return;
                }
            }

            TextAsset textAsset = Resources.Load <TextAsset>("input_adapter_init");

            if (textAsset != null)
            {
                using (System.IO.StringReader reader = new System.IO.StringReader(textAsset.text))
                {
                    InputLoaderXML inputLoader = new InputLoaderXML(reader);
                    inputLoader.Load(out _inputManager.inputConfigurations, out _inputManager.defaultConfiguration);
                    _selectionPath.Clear();
                }
            }
            else
            {
                EditorUtility.DisplayDialog("Error", "Failed to load default configurations for Input Adapter.", "OK");
            }
        }
예제 #6
0
    public override void DeserializeFromXml(XmlNode node)
    {
        if (!EnableModify())
        {
            return;
        }

        var t = node.Attributes["type"].InnerText;

        if (string.IsNullOrEmpty(t) || t != InputTypeString)
        {
            return;
        }

        if (InputLoaderXML.ReadElement(node, "Invert", out bool v))
        {
            m_invert.SetCustom(v);
        }

        if (InputLoaderXML.ReadElement(node, "Positive", out KeyCode p))
        {
            m_positive.SetCustom(p);
        }

        if (InputLoaderXML.ReadElement(node, "Negative", out KeyCode n))
        {
            m_negative.SetCustom(n);
        }

        if (InputLoaderXML.ReadElement(node, "Axis", out int a))
        {
            m_axis.SetCustom(a);
        }
    }
예제 #7
0
        public static ControlScheme LoadDefaultScheme(string controlSchemeName)
        {
            ControlScheme r = null;

            using (StringReader reader = new StringReader(xmlAsset.text)) {
                r = new InputLoaderXML(reader).Load(controlSchemeName);
            }
            return(r);
        }
예제 #8
0
		private void Awake()
		{
			string savePath = PathUtility.GetInputSaveFolder(m_exampleID) + "/input_config.xml";
			if(System.IO.File.Exists(savePath))
			{
				InputLoaderXML loader = new InputLoaderXML(savePath);
				InputManager.Load(loader);
			}
		}
예제 #9
0
        private void Awake()
        {
            string savePath = PathUtility.GetInputSaveFolder(m_exampleID) + "/input_config.xml";

            if (System.IO.File.Exists(savePath))
            {
                InputLoaderXML loader = new InputLoaderXML(savePath);
                InputManager.Load(loader);
            }
        }
        /// <summary>
        /// Loads the control schemes from an XML file, from Application.persistentDataPath.
        /// </summary>
        public static List <ControlScheme> LoadCustomControls()
        {
            List <ControlScheme> schemes = null;

            if (System.IO.File.Exists(customControlBindingsPath))
            {
                schemes = new InputLoaderXML(customControlBindingsPath).Load();
                Debug.Log("Loaded custom control bindings from :: " + customControlBindingsPath);
            }
            return(schemes);
        }
예제 #11
0
    /// <summary>
    /// 加载玩家的配置
    /// </summary>
    public void Load()
    {
        if (!File.Exists(ConfigFilePath))
        {
            return;
        }

        var loader = new InputLoaderXML(ConfigFilePath);

        loader.Load(ref this.joystickControlSchemes, ref this.pcControlSchemes);
    }
예제 #12
0
        public static void LoadSnapshot(TeamUtility.IO.InputManager inputManager)
        {
            if (!CanLoadSnapshot())
            {
                return;
            }

            InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile);

            inputManager.Load(inputLoader.Load());
        }
예제 #13
0
 public void Load()
 {
     if (PlayerPrefs.HasKey("ControlsMenu.InputConfig"))
     {
         string xml = PlayerPrefs.GetString("ControlsMenu.InputConfig");
         using (TextReader reader = new StringReader(xml)) {
             InputLoaderXML loader = new InputLoaderXML(reader);
             InputManager.Load(loader);
         }
     }
 }
예제 #14
0
        public static void LoadSnapshot(TeamUtility.IO.InputManager inputManager)
        {
            if (!CanLoadSnapshot())
            {
                return;
            }

            InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile);

            inputLoader.Load(out inputManager.inputConfigurations, out inputManager.defaultConfiguration);
        }
예제 #15
0
        public static void LoadSnapshot(InputManager inputManager)
        {
            if (!CanLoadSnapshot())
            {
                return;
            }

            InputLoaderXML inputLoader = new InputLoaderXML(m_snapshotFile);

            inputManager.SetSaveData(inputLoader.Load());
        }
예제 #16
0
 public static void PlayerPrefsLoad(string location)
 {
     if (PlayerPrefs.HasKey(location))
     {
         string xml = PlayerPrefs.GetString(location);
         using (TextReader reader = new StringReader(xml))
         {
             InputLoaderXML loader = new InputLoaderXML(reader);
             InputManager.Load(loader);
         }
     }
 }
예제 #17
0
        public static List <ControlScheme> LoadDefaultSchemes()
        {
            if (xmlAsset == null)
            {
                return(null);
            }

            List <ControlScheme> r = null;

            using (StringReader reader = new StringReader(xmlAsset.text)) {
                r = new InputLoaderXML(reader).Load();
            }
            return(r);
        }
        /// <summary>
        /// Loads the control schemes from an XML file, from Application.persistentDataPath.
        /// </summary>
        public static List <ControlScheme> LoadCustomControls()
        {
            List <ControlScheme> schemes = null;

#if UNITY_WINRT && !UNITY_EDITOR
            if (UnityEngine.Windows.File.Exists(customControlBindingsPath))
#else
            if (System.IO.File.Exists(customControlBindingsPath))
#endif
            {
                schemes = new InputLoaderXML(customControlBindingsPath).Load();
                Debug.Log("Loaded custom control bindings from :: " + customControlBindingsPath);
            }
            return(schemes);
        }
예제 #19
0
        private void ImportInputConfigurations()
        {
            string file = EditorUtility.OpenFilePanel("Import input profile", "", "xml");

            if (string.IsNullOrEmpty(file))
            {
                return;
            }

            bool replace = EditorUtility.DisplayDialog("Replace or Append", "Do you want to replace the current input configrations?", "Replace", "Append");

            if (replace)
            {
                InputLoaderXML inputLoader = new InputLoaderXML(file);
                inputLoader.Load(out _inputManager.inputConfigurations, out _inputManager.defaultConfiguration);
                _selectionPath.Clear();
            }
            else
            {
                List <InputConfiguration> configurations;
                string defaultConfig;

                InputLoaderXML inputLoader = new InputLoaderXML(file);
                inputLoader.Load(out configurations, out defaultConfig);
                if (configurations != null && configurations.Count > 0)
                {
                    foreach (var config in configurations)
                    {
                        _inputManager.inputConfigurations.Add(config);
                    }
                }
            }

            if (_searchString.Length > 0)
            {
                UpdateSearchResults();
            }
            Repaint();
        }
        public void ResetScheme()
        {
            ControlScheme defControlScheme = null;

            using (StringReader reader = new StringReader(m_defaultInputProfile.text))
            {
                defControlScheme = new InputLoaderXML(reader).Load(m_controlSchemeName);
            }

            if (defControlScheme != null)
            {
                ControlScheme controlScheme = InputManager.GetControlScheme(m_controlSchemeName);
                if (defControlScheme.Actions.Count == controlScheme.Actions.Count)
                {
                    for (int i = 0; i < defControlScheme.Actions.Count; i++)
                    {
                        controlScheme.Actions[i].Copy(defControlScheme.Actions[i]);
                    }

                    InputManager.Reinitialize();

                    RebindInputButton[] rebinders = GetComponentsInChildren <RebindInputButton>();
                    foreach (var t in rebinders)
                    {
                        t.RefreshText();
                    }
                }
                else
                {
                    Debug.LogError("Current and default control scheme don't have the same number of actions");
                }
            }
            else
            {
                Debug.LogErrorFormat("Default input profile doesn't contain a control scheme named '{0}'", m_controlSchemeName);
            }
        }