示例#1
0
		public static void LoadSnapshot(TeamUtility.IO.InputManager inputManager)
		{
			if(!CanLoadSnapshot())
				return;
			
			InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile);
            inputManager.Load(inputLoader.Load());
		}
        public static void LoadSnapshot(TeamUtility.IO.InputManager inputManager)
        {
            if(!CanLoadSnapshot())
                return;

            InputLoaderXML inputLoader = new InputLoaderXML(_snapshotFile);
            inputLoader.Load(out inputManager.inputConfigurations, out inputManager.defaultConfiguration);
        }
        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();
        }
        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");
            }
        }
		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");
			}
		}