예제 #1
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");
            }
        }
예제 #2
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");
            }
        }
예제 #3
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 static void LoadSnapshot(TeamUtility.IO.InputManager inputManager)
        {
            if (!CanLoadSnapshot())
            {
                return;
            }

            InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile);

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

            InputLoaderXML inputLoader = new InputLoaderXML(m_snapshotFile);

            inputManager.SetSaveData(inputLoader.Load());
        }
예제 #6
0
    /// <summary>
    /// 加载玩家的配置
    /// </summary>
    public void Load()
    {
        if (!File.Exists(ConfigFilePath))
        {
            return;
        }

        var loader = new InputLoaderXML(ConfigFilePath);

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

            InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile);

            inputManager.Load(inputLoader.Load());
        }
예제 #8
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();
        }