Ejemplo n.º 1
0
        public static bool OverwriteProjectSettings()
        {
            int    length = Application.dataPath.LastIndexOf('/');
            string projectSettingsFolder = string.Concat(Application.dataPath.Substring(0, length), "/ProjectSettings");
            string inputManagerPath      = string.Concat(projectSettingsFolder, "/InputManager.asset");

            if (!Directory.Exists(projectSettingsFolder))
            {
                EditorUtility.DisplayDialog("Error", "Unable to get the correct path to the ProjectSetting folder.", "OK");
                return(false);
            }

            if (!EditorUtility.DisplayDialog("Warning", "You chose not to export your old input settings. They will be lost forever. Are you sure you want to continue?", "Yes", "No"))
            {
                return(false);
            }

            InputConverter inputConverter = new InputConverter();

            inputConverter.GenerateDefaultUnityInputManager(inputManagerPath);

            EditorUtility.DisplayDialog("Success", "The input settings have been successfully replaced.\n\nYou might need to minimize and restore Unity to reimport the new settings.", "OK");

            return(true);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            InputConverter converter                          = new InputConverter();
            string         convertSourceFile                  = "InputManager.asset";
            string         convertDestinationFile             = "InputManager.xml";
            string         defaultInputManagerDestinationFile = "InputManager_Generated.asset";
            string         keyConverterFile                   = "KeyCodeConverter.cs";
            string         keyConverterTemplate               = File.ReadAllText("key_code_converter_template.txt");

            converter.ConvertUnityInputManager(convertSourceFile, convertDestinationFile);
            converter.GenerateDefaultUnityInputManager(defaultInputManagerDestinationFile);
            KeyNameGenerator.GenerateKeyNames(keyConverterTemplate, keyConverterFile);

            Console.WriteLine("Your key is: {0}", KeyCodeConverter.KeyToString(KeyCode.Joystick1Button11));
        }
Ejemplo n.º 3
0
        public static bool OverwriteProjectSettings()
        {
            int    length = Application.dataPath.LastIndexOf('/');
            string projectSettingsFolder = string.Concat(Application.dataPath.Substring(0, length), "/ProjectSettings");
            string inputManagerPath      = string.Concat(projectSettingsFolder, "/InputManager.asset");

            if (!Directory.Exists(projectSettingsFolder))
            {
                EditorUtility.DisplayDialog("Error", "Unable to get the correct path to the ProjectSetting folder.", "OK");
                return(false);
            }

            if (!File.Exists(inputManagerPath))
            {
                EditorUtility.DisplayDialog("Error", "Unable to get the correct path to the InputManager file from the ProjectSettings folder.", "OK");
                return(false);
            }

            int    option     = EditorUtility.DisplayDialogComplex("Warning", "Do you want to export your old input settings?\n\nYour project needs to have asset serialization mode set to 'Force Text' in the Editor Settings. If text serialization is not enabled press the Abort button.\n\nYou can resume this process after text serialization is enabled from the File menu.", "Yes", "No", "Abort");
            string exportPath = null;

            if (option == 0)
            {
                exportPath = EditorUtility.SaveFilePanel("Export old input axes", "", "unity_input_export", "xml");
                if (string.IsNullOrEmpty(exportPath))
                {
                    if (!EditorUtility.DisplayDialog("Warning", "You chose not to export your old input settings. They will be lost forever. Are you sure you want to continue?", "Yes", "No"))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (option == 1)
                {
                    if (!EditorUtility.DisplayDialog("Warning", "You chose not to export your old input settings. They will be lost forever. Are you sure you want to continue?", "Yes", "No"))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            InputConverter inputConverter = new InputConverter();

            if (!string.IsNullOrEmpty(exportPath))
            {
                try
                {
                    inputConverter.ConvertUnityInputManager(inputManagerPath, exportPath);
                }
                catch (System.Exception ex)
                {
                    Debug.LogException(ex);

                    string message = "Failed to export your old input settings. Please make sure asset serialization mode is set to 'Forced Text' in the Editor Settings.\n\nDo you want to continue? If you continue your old input settings will be lost forever.";
                    if (!EditorUtility.DisplayDialog("Error", message, "Yes", "No"))
                    {
                        return(false);
                    }
                }
            }

            inputConverter.GenerateDefaultUnityInputManager(inputManagerPath);

            EditorUtility.DisplayDialog("Success", "The input settings have been successfully replaced.\n\nYou might need to minimize and restore Unity to reimport the new settings.", "OK");

            return(true);
        }