private void SaveFile()
        {
            SteamVR_Input.actionFile.SaveHelperLists();

            SteamVR_Input.actionFile.Save(SteamVR_Input.GetActionsFilePath());

            SteamVR_Input_ActionManifest_Manager.CleanBindings(true);

            Debug.Log("<b>[SteamVR Input]</b> Saved actions manifest successfully.");

            SteamVR_Input_Generator.BeginGeneration();
        }
Пример #2
0
        protected static void ImportPartialBinding(SteamVR_PartialInputBindings partialBinding)
        {
            SteamVR_Input.InitializeFile();
            SteamVR_Input_ActionFile currentActionsFile = SteamVR_Input.actionFile;

            SteamVR_Input_ActionFile newActionsFile =
                ReadJson <SteamVR_Input_ActionFile>(partialBinding.GetActionsPath());

            /*
             * int sets = ImportActionSets(currentActionsFile, newActionsFile);
             * int locs = ImportLocalization(currentActionsFile, newActionsFile, partialBinding);
             * int actions = ImportActions(currentActionsFile, newActionsFile);
             */

            ImportActionSets(currentActionsFile, newActionsFile);
            ImportLocalization(currentActionsFile, newActionsFile, partialBinding);
            ImportActions(currentActionsFile, newActionsFile);

            if (SteamVR_Input.HasFileInMemoryBeenModified())
            {
                SteamVR_Input.actionFile.Save(SteamVR_Input.actionsFilePath);

                Debug.Log("<b>[SteamVR]</b> Saved new actions file: " + SteamVR_Input.actionsFilePath);
            }

            ImportBindings(currentActionsFile, newActionsFile, partialBinding.GetDirectory());

            partialBinding.imported = true;
            partialBinding.Save();

            SteamVR_Input.InitializeFile(true);
            SteamVR_Input_EditorWindow.ReopenWindow();

            //todo: ask first?

            /*string dialogText = string.Format("{0} new action sets, {1} new actions, and {2} new localization strings have been added. Would you like to regenerate SteamVR Input code files?", sets, actions, locs);
             *
             * bool confirm = EditorUtility.DisplayDialog("SteamVR Input", dialogText, "Generate", "Cancel");
             * if (confirm)
             *  SteamVR_Input_Generator.BeginGeneration();
             */

            SteamVR_Input_Generator.BeginGeneration();

            Debug.Log("<b>[SteamVR]</b> Reloaded actions file with additional actions from " + partialBinding.name);
        }
        protected static void ReplaceBinding(SteamVR_PartialInputBindings partialBinding)
        {
            SteamVR_Input.DeleteManifestAndBindings();

            string newActionsFilePath = partialBinding.GetActionsPath();

            if (File.Exists(newActionsFilePath))
            {
                File.Copy(newActionsFilePath, SteamVR_Input.GetActionsFilePath());
            }

            string bindingsFolder = SteamVR_Input.GetActionsFileFolder();

            SteamVR_Input_ActionFile newActionsFile = ReadJson <SteamVR_Input_ActionFile>(SteamVR_Input.GetActionsFilePath());
            string partialBindingDirectory          = partialBinding.GetDirectory();

            foreach (var newDefaultPath in newActionsFile.default_bindings)
            {
                string bindingPath    = Path.Combine(partialBindingDirectory, newDefaultPath.binding_url);
                string newBindingPath = Path.Combine(bindingsFolder, newDefaultPath.binding_url);
                File.Copy(bindingPath, newBindingPath, true);
            }

            partialBinding.imported = true;
            partialBinding.Save();

            SteamVR_Input.InitializeFile(true);
            SteamVR_Input_EditorWindow.ReopenWindow();

            //todo: ask first?

            /*string dialogText = string.Format("{0} new action sets, {1} new actions, and {2} new localization strings have been added. Would you like to regenerate SteamVR Input code files?", sets, actions, locs);
             *
             * bool confirm = EditorUtility.DisplayDialog("SteamVR Input", dialogText, "Generate", "Cancel");
             * if (confirm)
             *  SteamVR_Input_Generator.BeginGeneration();
             */

            SteamVR_Input_Generator.BeginGeneration();

            Debug.Log("<b>[SteamVR Input]</b> Reloaded with new actions from " + partialBinding.name);
        }
        private void SaveFile()
        {
            FileInfo existingActionsFile = new FileInfo(SteamVR_Input.actionsFilePath);

            if (existingActionsFile.Exists)
            {
                existingActionsFile.IsReadOnly = false;
            }

            SteamVR_Input.actionFile.SaveHelperLists();

            //SanitizeActionFile(); //todo: shouldn't we be doing this?

            string json = JsonConvert.SerializeObject(SteamVR_Input.actionFile, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            File.WriteAllText(SteamVR_Input.actionsFilePath, json);

            Debug.Log("[SteamVR Input] Saved actions manifest successfully.");

            SteamVR_Input_Generator.BeginGeneration();
        }