private void OnGUI()
        {
            if (headerLabelStyle == null)
            {
                headerLabelStyle = new GUIStyle(EditorStyles.boldLabel);
            }
            if (multiLineStyle == null)
            {
                multiLineStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
            }
            if (smallMultiLineStyle == null)
            {
                smallMultiLineStyle           = new GUIStyle(EditorStyles.wordWrappedLabel);
                smallMultiLineStyle.fontSize  = EditorStyles.miniLabel.fontSize;
                smallMultiLineStyle.fontStyle = FontStyle.Italic;
            }

            SteamVR_Input.InitializeFile();
            EditorGUILayout.Space();


            EditorGUILayout.LabelField("Actions manifest", headerLabelStyle);
            EditorGUILayout.LabelField(string.Format("Path: {0}", SteamVR_Input.GetActionsFilePath(true)));

            DrawRefreshButton();


            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            DrawPartial();


            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            DrawOverwriteOption();

            DrawDeleteUnusedActions();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            bool delete = GUILayout.Button("Delete generated input folder");

            GUILayout.FlexibleSpace();
            bool showSettings = GUILayout.Button("SteamVR Settings");

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

            if (delete)
            {
                bool confirm = EditorUtility.DisplayDialog("Confirmation", "Are you sure you want to delete the input code files? This may make your project unable to compile.", "Delete", "Cancel");
                if (confirm)
                {
                    SteamVR_Input_Generator.DeleteGeneratedFolder();
                }
            }

            if (showSettings)
            {
                Selection.activeObject = SteamVR_Settings.instance;
            }
        }
 private void Initialize(bool force = false)
 {
     SteamVR_Input.InitializeFile(force, false);
     InitializeEditorValues();
     initialized = true;
 }
 private bool HasBeenModified()
 {
     SteamVR_Input.actionFile.SaveHelperLists();
     return(SteamVR_Input.HasFileInMemoryBeenModified());
 }
        private static SteamVR CreateInstance()
        {
            try
            {
                var error = EVRInitError.None;
                if (!SteamVR.usingNativeSupport)
                {
                    string errorLog = "[SteamVR] Initialization failed. ";

                    if (XRSettings.enabled == false)
                    {
                        errorLog += "VR may be disabled in player settings. Go to player settings in the editor and check the 'Virtual Reality Supported' checkbox'. ";
                    }
                    if (XRSettings.supportedDevices.Contains("OpenVR") == false)
                    {
                        errorLog += "OpenVR is not in your list of supported virtual reality SDKs. Add it to the list in player settings. ";
                    }

                    errorLog += "To force OpenVR initialization call SteamVR.Initialize(true). ";

                    Debug.Log(errorLog);
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                // Verify common interfaces are valid.

                OpenVR.GetGenericInterface(OpenVR.IVRCompositor_Version, ref error);
                if (error != EVRInitError.None)
                {
                    ReportError(error);
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                OpenVR.GetGenericInterface(OpenVR.IVROverlay_Version, ref error);
                if (error != EVRInitError.None)
                {
                    ReportError(error);
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                settings = SteamVR_Settings.instance;

                SteamVR_Input.PreInitialize();

                if (Application.isEditor)
                {
                    IdentifyApplication();
                }

                SteamVR_Input.IdentifyActionsFile();

                if (SteamVR_Settings.instance.inputUpdateMode != SteamVR_UpdateModes.Nothing || SteamVR_Settings.instance.poseUpdateMode != SteamVR_UpdateModes.Nothing)
                {
                    SteamVR_Input.Initialize();
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
                SteamVR_Events.Initialized.Send(false);
                return(null);
            }

            _enabled = true;
            SteamVR_Events.Initialized.Send(true);
            return(new SteamVR());
        }
 private static SteamVR CreateInstance()
 {
     SteamVR.initializedState = SteamVR.InitializedStates.Initializing;
     try
     {
         EVRInitError evrinitError = EVRInitError.None;
         OpenVR.GetGenericInterface("IVRCompositor_022", ref evrinitError);
         OpenVR.Init(ref evrinitError, EVRApplicationType.VRApplication_Scene, "");
         CVRSystem           system              = OpenVR.System;
         string              manifestFile        = SteamVR.GetManifestFile();
         EVRApplicationError evrapplicationError = OpenVR.Applications.AddApplicationManifest(manifestFile, true);
         if (evrapplicationError != EVRApplicationError.None)
         {
             UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> Error adding vr manifest file: " + evrapplicationError.ToString());
         }
         int id = Process.GetCurrentProcess().Id;
         OpenVR.Applications.IdentifyApplication((uint)id, SteamVR_Settings.instance.editorAppKey);
         UnityEngine.Debug.Log("Is HMD here? " + OpenVR.IsHmdPresent().ToString());
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR.ReportGeneralErrors();
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         OpenVR.GetGenericInterface("IVROverlay_021", ref evrinitError);
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         OpenVR.GetGenericInterface("IVRInput_007", ref evrinitError);
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         SteamVR.settings = SteamVR_Settings.instance;
         if (Application.isEditor)
         {
             SteamVR.IdentifyEditorApplication(true);
         }
         SteamVR_Input.IdentifyActionsFile(true);
         if (SteamVR_Settings.instance.inputUpdateMode != SteamVR_UpdateModes.Nothing || SteamVR_Settings.instance.poseUpdateMode != SteamVR_UpdateModes.Nothing)
         {
             SteamVR_Input.Initialize(false);
         }
     }
     catch (Exception arg)
     {
         UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> " + arg);
         SteamVR_Events.Initializing.Send(false);
         return(null);
     }
     SteamVR._enabled         = true;
     SteamVR.initializedState = SteamVR.InitializedStates.InitializeSuccess;
     SteamVR_Events.Initializing.Send(true);
     return(new SteamVR());
 }
Beispiel #6
0
        private static string GetManifestFile()
        {
            string currentPath = Application.dataPath;
            int    lastIndex   = currentPath.LastIndexOf('/');

            currentPath = currentPath.Remove(lastIndex, currentPath.Length - lastIndex);

            string fullPath = Path.Combine(currentPath, "unityProject.vrmanifest");

            FileInfo fullManifestPath = new FileInfo(SteamVR_Input.GetActionsFilePath());

            if (File.Exists(fullPath))
            {
                string jsonText = File.ReadAllText(fullPath);
                SteamVR_Input_ManifestFile existingFile = Valve.Newtonsoft.Json.JsonConvert.DeserializeObject <SteamVR_Input_ManifestFile>(jsonText);

                if (existingFile != null && existingFile.applications != null && existingFile.applications.Count > 0 &&
                    existingFile.applications[0].app_key != SteamVR_Settings.instance.editorAppKey)
                {
                    Debug.Log("<b>[SteamVR]</b> Deleting existing VRManifest because it has a different app key.");
                    FileInfo existingInfo = new FileInfo(fullPath);
                    if (existingInfo.IsReadOnly)
                    {
                        existingInfo.IsReadOnly = false;
                    }
                    existingInfo.Delete();
                }

                if (existingFile != null && existingFile.applications != null && existingFile.applications.Count > 0 &&
                    existingFile.applications[0].action_manifest_path != fullManifestPath.FullName)
                {
                    Debug.Log("<b>[SteamVR]</b> Deleting existing VRManifest because it has a different action manifest path:" +
                              "\nExisting:" + existingFile.applications[0].action_manifest_path +
                              "\nNew: " + fullManifestPath.FullName);
                    FileInfo existingInfo = new FileInfo(fullPath);
                    if (existingInfo.IsReadOnly)
                    {
                        existingInfo.IsReadOnly = false;
                    }
                    existingInfo.Delete();
                }
            }

            if (File.Exists(fullPath) == false)
            {
                SteamVR_Input_ManifestFile manifestFile = new SteamVR_Input_ManifestFile();
                manifestFile.source = "Unity";
                SteamVR_Input_ManifestFile_Application manifestApplication = new SteamVR_Input_ManifestFile_Application();
                manifestApplication.app_key = SteamVR_Settings.instance.editorAppKey;
                manifestApplication.action_manifest_path = fullManifestPath.FullName;
                manifestApplication.launch_type          = "url";
                //manifestApplication.binary_path_windows = SteamVR_Utils.ConvertToForwardSlashes(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                //manifestApplication.binary_path_linux = SteamVR_Utils.ConvertToForwardSlashes(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                //manifestApplication.binary_path_osx = SteamVR_Utils.ConvertToForwardSlashes(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                manifestApplication.url = "steam://launch/";
                manifestApplication.strings.Add("en_us", new SteamVR_Input_ManifestFile_ApplicationString()
                {
                    name = string.Format("{0} [Testing]", Application.productName)
                });

                /*
                 * var bindings = new System.Collections.Generic.List<SteamVR_Input_ManifestFile_Application_Binding>();
                 *
                 * SteamVR_Input.InitializeFile();
                 * if (SteamVR_Input.actionFile != null)
                 * {
                 *  string[] bindingFiles = SteamVR_Input.actionFile.GetFilesToCopy(true);
                 *  if (bindingFiles.Length == SteamVR_Input.actionFile.default_bindings.Count)
                 *  {
                 *      for (int bindingIndex = 0; bindingIndex < bindingFiles.Length; bindingIndex++)
                 *      {
                 *          SteamVR_Input_ManifestFile_Application_Binding binding = new SteamVR_Input_ManifestFile_Application_Binding();
                 *          binding.binding_url = bindingFiles[bindingIndex];
                 *          binding.controller_type = SteamVR_Input.actionFile.default_bindings[bindingIndex].controller_type;
                 *          bindings.Add(binding);
                 *      }
                 *      manifestApplication.bindings = bindings;
                 *  }
                 *  else
                 *  {
                 *      Debug.LogError("<b>[SteamVR]</b> Mismatch in available binding files.");
                 *  }
                 * }
                 * else
                 * {
                 *  Debug.LogError("<b>[SteamVR]</b> Could not load actions file.");
                 * }
                 */

                manifestFile.applications = new System.Collections.Generic.List <SteamVR_Input_ManifestFile_Application>();
                manifestFile.applications.Add(manifestApplication);

                string json = Valve.Newtonsoft.Json.JsonConvert.SerializeObject(manifestFile, Valve.Newtonsoft.Json.Formatting.Indented,
                                                                                new Valve.Newtonsoft.Json.JsonSerializerSettings {
                    NullValueHandling = Valve.Newtonsoft.Json.NullValueHandling.Ignore
                });

                File.WriteAllText(fullPath, json);
            }

            return(fullPath);
        }
Beispiel #7
0
        private static SteamVR CreateInstance()
        {
            initializedState = InitializedStates.Initializing;

            try
            {
                var error = EVRInitError.None;
                if (!SteamVR.usingNativeSupport && !isStandalone)
                {
                    ReportGeneralErrors();
                    initializedState = InitializedStates.InitializeFailure;
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                // Verify common interfaces are valid.

                OpenVR.GetGenericInterface(OpenVR.IVRCompositor_Version, ref error);
                if (error != EVRInitError.None)
                {
                    initializedState = InitializedStates.InitializeFailure;
                    ReportError(error);
                    ReportGeneralErrors();
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                OpenVR.GetGenericInterface(OpenVR.IVROverlay_Version, ref error);
                if (error != EVRInitError.None)
                {
                    initializedState = InitializedStates.InitializeFailure;
                    ReportError(error);
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                OpenVR.GetGenericInterface(OpenVR.IVRInput_Version, ref error);
                if (error != EVRInitError.None)
                {
                    initializedState = InitializedStates.InitializeFailure;
                    ReportError(error);
                    SteamVR_Events.Initialized.Send(false);
                    return(null);
                }

                settings = SteamVR_Settings.instance;

                if (Application.isEditor)
                {
                    IdentifyEditorApplication();
                }

                SteamVR_Input.IdentifyActionsFile();

                if (SteamVR_Settings.instance.inputUpdateMode != SteamVR_UpdateModes.Nothing || SteamVR_Settings.instance.poseUpdateMode != SteamVR_UpdateModes.Nothing)
                {
                    SteamVR_Input.Initialize();

#if UNITY_EDITOR
                    if (SteamVR_Input.IsOpeningSetup())
                    {
                        return(null);
                    }
#endif
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("<b>[SteamVR]</b> " + e);
                SteamVR_Events.Initialized.Send(false);
                return(null);
            }

            _enabled         = true;
            initializedState = InitializedStates.InitializeSuccess;
            SteamVR_Events.Initialized.Send(true);
            return(new SteamVR());
        }
 protected void LateUpdate()
 {
     SteamVR_Input.LateUpdate();
 }
 protected void Update()
 {
     SteamVR_Input.Update();
 }
        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);
        }
 protected void FixedUpdate()
 {
     SteamVR_Input.FixedUpdate();
 }
        public static void CleanBindings(bool verbose = false)
        {
            SteamVR_Input.InitializeFile(true);
            SteamVR_Input_ActionFile currentActionsFile = SteamVR_Input.actionFile;

            for (int localizationIndex = 0; localizationIndex < currentActionsFile.localization.Count; localizationIndex++)
            {
                Dictionary <string, string> dictionary = currentActionsFile.localization[localizationIndex];
                bool removed;
                do
                {
                    removed = false;
                    string missingAction = null;
                    foreach (string key in dictionary.Keys)
                    {
                        if (key == SteamVR_Input_ActionFile_LocalizationItem.languageTagKeyName)
                        {
                            continue;
                        }

                        if (currentActionsFile.actions.Any(action => string.Equals(action.name, key, StringComparison.CurrentCultureIgnoreCase)) == false)
                        {
                            missingAction = key;
                        }
                    }

                    if (missingAction != null)
                    {
                        removed = true;
                        dictionary.Remove(missingAction);
                        if (verbose)
                        {
                            Debug.Log("<b>[SteamVR Input]</b> Removing localization entry for: " + missingAction);
                        }
                    }
                } while (removed);
            }

            for (int bindingIndex = 0; bindingIndex < currentActionsFile.default_bindings.Count; bindingIndex++)
            {
                SteamVR_Input_ActionFile_DefaultBinding currentBinding = currentActionsFile.default_bindings[bindingIndex];

                string bindingPath = Path.Combine(SteamVR_Input.GetActionsFileFolder(), currentBinding.binding_url);
                if (File.Exists(bindingPath) == false)
                {
                    if (verbose)
                    {
                        Debug.Log("<b>[SteamVR Input]</b> Removing binding entry for missing file: '" + currentBinding.controller_type + "' at: " + bindingPath);
                    }

                    currentActionsFile.default_bindings.RemoveAt(bindingIndex);
                    bindingIndex--;
                    continue;
                }

                SteamVR_Input_BindingFile bindingFile = GetBindingFileObject(bindingPath);
                if (bindingFile == null)
                {
                    Debug.LogError("<b>[SteamVR Input]</b> Error parsing binding file for: '" + currentBinding.controller_type + "' at: " + bindingPath);
                    continue;
                }

                int changed = 0;

                foreach (var actionList in bindingFile.bindings)
                {
                    for (int itemIndex = 0; itemIndex < actionList.Value.chords.Count; itemIndex++)
                    {
                        string outputActionPath = actionList.Value.chords[itemIndex].output;
                        if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
                        {
                            if (verbose)
                            {
                                Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing chord binding for action: " + outputActionPath);
                            }

                            actionList.Value.chords.RemoveAt(itemIndex);
                            itemIndex--;
                            changed++;
                        }
                    }

                    for (int itemIndex = 0; itemIndex < actionList.Value.haptics.Count; itemIndex++)
                    {
                        string outputActionPath = actionList.Value.haptics[itemIndex].output;
                        if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
                        {
                            if (verbose)
                            {
                                Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing haptics binding for action: " + outputActionPath);
                            }

                            actionList.Value.haptics.RemoveAt(itemIndex);
                            itemIndex--;
                            changed++;
                        }
                    }

                    for (int itemIndex = 0; itemIndex < actionList.Value.poses.Count; itemIndex++)
                    {
                        string outputActionPath = actionList.Value.poses[itemIndex].output;
                        if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
                        {
                            if (verbose)
                            {
                                Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing pose binding for action: " + outputActionPath);
                            }

                            actionList.Value.poses.RemoveAt(itemIndex);
                            itemIndex--;
                            changed++;
                        }
                    }

                    for (int itemIndex = 0; itemIndex < actionList.Value.skeleton.Count; itemIndex++)
                    {
                        string outputActionPath = actionList.Value.skeleton[itemIndex].output;
                        if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
                        {
                            if (verbose)
                            {
                                Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing skeleton binding for action: " + outputActionPath);
                            }

                            actionList.Value.skeleton.RemoveAt(itemIndex);
                            itemIndex--;
                            changed++;
                        }
                    }

                    for (int itemIndex = 0; itemIndex < actionList.Value.sources.Count; itemIndex++)
                    {
                        string outputActionPath = actionList.Value.sources[itemIndex].GetOutput();
                        if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
                        {
                            if (verbose)
                            {
                                Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing source binding for action: " + outputActionPath);
                            }

                            actionList.Value.sources.RemoveAt(itemIndex);
                            itemIndex--;
                            changed++;
                        }
                    }
                }

                if (changed > 0)
                {
                    WriteBindingFileObject(bindingFile, bindingPath);
                }
            }

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

                if (verbose)
                {
                    Debug.Log("<b>[SteamVR Input]</b> Saved new actions file: " + SteamVR_Input.GetActionsFilePath());
                }
            }
        }
        protected static void ImportBindings(SteamVR_Input_ActionFile currentActionsFile, SteamVR_Input_ActionFile newActionsFile, string directory)
        {
            foreach (var newDefaultPath in newActionsFile.default_bindings)
            {
                if (currentActionsFile.default_bindings.Any(currentDefaultPath => newDefaultPath.controller_type == currentDefaultPath.controller_type) == false)
                {
                    currentActionsFile.default_bindings.Add(newDefaultPath.GetCopy());

                    string bindingPath = Path.Combine(directory, newDefaultPath.binding_url);
                    File.Copy(bindingPath, newDefaultPath.binding_url);
                }
                else
                {
                    string currentBindingDirectory = SteamVR_Input.GetActionsFileFolder();
                    string currentBindingPath      = currentActionsFile.default_bindings.First(binding => binding.controller_type == newDefaultPath.controller_type).binding_url;
                    currentBindingPath = Path.Combine(currentBindingDirectory, currentBindingPath);

                    SteamVR_Input_BindingFile currentBindingFile = GetBindingFileObject(currentBindingPath);
                    if (currentBindingFile == null)
                    {
                        Debug.LogError("<b>[SteamVR]</b> There was an error deserializing the binding at path: " + currentBindingPath);
                        continue;
                    }

                    SteamVR_Input_BindingFile importingBindingFile = GetBindingFileObject(Path.Combine(directory, newDefaultPath.binding_url));
                    if (importingBindingFile == null)
                    {
                        Debug.LogError("<b>[SteamVR]</b> There was an error deserializing the binding at path: " + Path.Combine(directory, newDefaultPath.binding_url));
                        continue;
                    }

                    bool changed = false;

                    foreach (var importingActionList in importingBindingFile.bindings)
                    {
                        if (currentBindingFile.bindings.Any(binding => binding.Key == importingActionList.Key))
                        {
                            var currentSetBinding = currentBindingFile.bindings.FirstOrDefault(binding => binding.Key == importingActionList.Key);

                            //todo: better merge? if we don't have an exact copy of the item then we add a new one

                            foreach (var importingChord in importingActionList.Value.chords)
                            {
                                if (currentSetBinding.Value.chords.Any(currentChord => importingChord.Equals(currentChord)) == false)
                                {
                                    changed = true;
                                    currentSetBinding.Value.chords.Add(importingChord);
                                }
                            }

                            foreach (var importingHaptic in importingActionList.Value.haptics)
                            {
                                if (currentSetBinding.Value.haptics.Any(currentHaptic => importingHaptic.Equals(currentHaptic)) == false)
                                {
                                    changed = true;
                                    currentSetBinding.Value.haptics.Add(importingHaptic);
                                }
                            }

                            foreach (var importingPose in importingActionList.Value.poses)
                            {
                                if (currentSetBinding.Value.poses.Any(currentPose => importingPose.Equals(currentPose)) == false)
                                {
                                    changed = true;
                                    currentSetBinding.Value.poses.Add(importingPose);
                                }
                            }

                            foreach (var importingSkeleton in importingActionList.Value.skeleton)
                            {
                                if (currentSetBinding.Value.skeleton.Any(currentSkeleton => importingSkeleton.Equals(currentSkeleton)) == false)
                                {
                                    changed = true;
                                    currentSetBinding.Value.skeleton.Add(importingSkeleton);
                                }
                            }

                            foreach (var importingSource in importingActionList.Value.sources)
                            {
                                if (currentSetBinding.Value.sources.Any(currentSource => importingSource.Equals(currentSource)) == false)
                                {
                                    changed = true;
                                    currentSetBinding.Value.sources.Add(importingSource);
                                }
                            }
                        }
                        else
                        {
                            changed = true;
                            currentBindingFile.bindings.Add(importingActionList.Key, importingActionList.Value);
                        }
                    }

                    if (changed)
                    {
                        WriteBindingFileObject(currentBindingFile, currentBindingPath);
                    }
                }
            }
        }
Beispiel #14
0
 private void Initialize()
 {
     SteamVR_Input.InitializeFile();
     InitializeEditorValues();
     initialized = true;
 }
Beispiel #15
0
        private void OnGUI()
        {
            if (headerLabelStyle == null)
            {
                headerLabelStyle = new GUIStyle(EditorStyles.boldLabel);
            }
            if (multiLineStyle == null)
            {
                multiLineStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
            }
            if (smallMultiLineStyle == null)
            {
                smallMultiLineStyle           = new GUIStyle(EditorStyles.wordWrappedLabel);
                smallMultiLineStyle.fontSize  = EditorStyles.miniLabel.fontSize;
                smallMultiLineStyle.fontStyle = FontStyle.Italic;
            }

            if (folderName == null)
            {
                folderName = "SteamVR_" + SteamVR.GenerateCleanProductName();
            }

            SteamVR_Input.InitializeFile();
            EditorGUILayout.Space();


            EditorGUILayout.LabelField("Partial input bindings", headerLabelStyle);
            EditorGUILayout.LabelField(
                "When you create a partial bindings folder you can include that anywhere inside your asset package folder and it will automatically be found and imported to the user's project on load.",
                multiLineStyle);
            EditorGUILayout.LabelField("note: You can rename the folder but do not rename any files inside.",
                                       smallMultiLineStyle);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            folderName = EditorGUILayout.TextField("Name", folderName);

            EditorGUILayout.Space();

            version = EditorGUILayout.IntField("Version", version);
            EditorGUILayout.LabelField("note: only whole numbers", smallMultiLineStyle);

            EditorGUILayout.Space();

            overwriteOldActions = EditorGUILayout.Toggle("Overwrite old actions", overwriteOldActions);
            EditorGUILayout.LabelField(
                "If the person importing your asset package has a previous version of your package this determines whether or not to overwrite actions and bindings that have the same name.",
                smallMultiLineStyle);

            EditorGUILayout.Space();

            removeOldVersionActions =
                EditorGUILayout.Toggle("Remove unused actions from old versions", overwriteOldActions);
            EditorGUILayout.LabelField(
                "If the person importing your asset package has a previous version of your package that has actions that are not used in the new version of your package this determines whether or not to delete those actions.",
                smallMultiLineStyle);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            bool create = GUILayout.Button("Create");

            if (create)
            {
                SteamVR_Input_ActionManifest_Manager.CreatePartial(folderName, version, overwriteOldActions,
                                                                   removeOldVersionActions);
            }
        }
Beispiel #16
0
 private static void OnReloadScripts()
 {
     SteamVR_Input.CheckOldLocation();
     CopyFiles();
 }