private void DrawRefreshButton()
        {
            EditorGUILayout.BeginHorizontal();
            bool refresh = GUILayout.Button("Refresh");

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            if (refresh)
            {
                SteamVR_Input_EditorWindow.ReopenWindow();
            }
        }
Exemplo n.º 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);
        }