您的位置: 首页 - 站长

做冲压件加工有什么好网站台州制作网站软件

当前位置: 首页 > news >正文

做冲压件加工有什么好网站,台州制作网站软件,怎么做旅游网站,wordpress vs最近有一个项目是用Steam VR开发的#xff0c;里面部分场景是用VRTK框架做的#xff0c;还有一部分是用SteamVR SDK自带的Player预制直接开发的。 这样本身没有问题#xff0c;因为最终都是通过SteamVR SDK处理的#xff0c;VRTK也管理好了SteamVR的逻辑#xff0c;并且支…最近有一个项目是用Steam VR开发的里面部分场景是用VRTK框架做的还有一部分是用SteamVR SDK自带的Player预制直接开发的。 这样本身没有问题因为最终都是通过SteamVR SDK处理的VRTK也管理好了SteamVR的逻辑并且支持动态切换比如切换成Oculus的。 然后现在遇到一个问题还有一个项目是用Unity自带的XR开发的Package Manager导入XR相关的插件实现的。 需要将XR开发的项目移植到Steam VR项目来然后事情就开始了。 SteamVR的场景可以运行通过Pico以及Quest串流还有htc头盔都能正常识别手柄也能控制。 但是XR场景就出现问题了头盔无法识别。 经过一步步排查发现是XR Plug-in Management这里需要设置不同的XRLoader。 而SteamVR是OpenVR Loader而XR是OpenXR因为OpenVR Loader在前所以激活的是OpenVR Loader这也是为什么SteamVR场景可以运行而XR场景不行。 我们看看unity的源代码是怎么写的发现这里面是有activeLoader的概念也就是一次只能一个Loader运行。 using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices;using UnityEditor;using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UIElements; using UnityEngine.Serialization; using UnityEngine.XR.Management;[assembly: InternalsVisibleTo(Unity.XR.Management.Tests)] [assembly: InternalsVisibleTo(Unity.XR.Management.EditorTests)] namespace UnityEngine.XR.Management {/// summary/// Class to handle active loader and subsystem management for XR. This class is to be added as a/// ScriptableObject asset in your project and should only be referenced by the see crefXRGeneralSettings//// instance for its use.////// Given a list of loaders, it will attempt to load each loader in the given order. The first/// loader that is successful wins and all remaining loaders are ignored. The loader/// that succeeds is accessible through the see crefactiveLoader/ property on the manager.////// Depending on configuration the see crefXRManagerSettings/ instance will automatically manage the active loader/// at correct points in the application lifecycle. The user can override certain points in the active loader lifecycle/// and manually manage them by toggling the see crefautomaticLoading/ and see crefautomaticRunning//// properties. Disabling see crefautomaticLoading/ implies the the user is responsible for the full lifecycle/// of the XR session normally handled by the see crefXRManagerSettings/ instance. Toggling this to false also toggles/// see crefautomaticRunning/ false.////// Disabling see crefautomaticRunning/ only implies that the user is responsible for starting and stopping/// the see crefactiveLoader/ through the see crefStartSubsystems/ and see crefStopSubsystems/ APIs.////// Automatic lifecycle management is executed as follows////// * Runtime Initialize - see crefInitializeLoader/. The loader list will be iterated over and the first successful loader will be set as the active loader./// * Start - see crefStartSubsystems/. Ask the active loader to start all subsystems./// * OnDisable - see crefStopSubsystems/. Ask the active loader to stop all subsystems./// * OnDestroy - see crefDeinitializeLoader/. Deinitialize and remove the active loader./// /summarypublic sealed class XRManagerSettings : ScriptableObject{[HideInInspector]bool m_InitializationComplete false;#pragma warning disable 414// This property is only used by the scriptable object editing part of the system and as such no one// directly references it. Have to manually disable the console warning here so that we can// get a clean console report.[HideInInspector][SerializeField]bool m_RequiresSettingsUpdate false; #pragma warning restore 414[SerializeField][Tooltip(Determines if the XR Manager instance is responsible for creating and destroying the appropriate loader instance.)][FormerlySerializedAs(AutomaticLoading)]bool m_AutomaticLoading false;/// summary/// Get and set Automatic Loading state for this manager. When this is true, the manager will automatically call/// see crefInitializeLoader/ and see crefDeinitializeLoader/ for you. When false see crefautomaticRunning//// is also set to false and remains that way. This means that disabling automatic loading disables all automatic behavior/// for the manager./// /summarypublic bool automaticLoading{get { return m_AutomaticLoading; }set { m_AutomaticLoading value; }}[SerializeField][Tooltip(Determines if the XR Manager instance is responsible for starting and stopping subsystems for the active loader instance.)][FormerlySerializedAs(AutomaticRunning)]bool m_AutomaticRunning false;/// summary/// Get and set automatic running state for this manager. When set to true the manager will call see crefStartSubsystems//// and see crefStopSubsystems/ APIs at appropriate times. When set to false, or when see crefautomaticLoading/ is false/// then it is up to the user of the manager to handle that same functionality./// /summarypublic bool automaticRunning{get { return m_AutomaticRunning; }set { m_AutomaticRunning value; }}[SerializeField][Tooltip(List of XR Loader instances arranged in desired load order.)][FormerlySerializedAs(Loaders)]ListXRLoader m_Loaders new ListXRLoader();// Maintains a list of registered loaders that is immutable at runtime.[SerializeField][HideInInspector]HashSetXRLoader m_RegisteredLoaders new HashSetXRLoader();/// summary/// List of loaders currently managed by this XR Manager instance./// /summary/// remarks/// Modifying the list of loaders at runtime is undefined behavior and could result in a crash or memory leak./// Use see crefactiveLoaders/ to retrieve the currently ordered list of loaders. If you need to mutate/// the list at runtime, use see crefTryAddLoader/, see crefTryRemoveLoader/, and/// see crefTrySetLoaders/./// /remarks[Obsolete(XRManagerSettings.loaders property is obsolete. Use XRManagerSettings.activeLoaders instead to get a list of the current loaders.)]public ListXRLoader loaders{get { return m_Loaders; } #if UNITY_EDITORset { m_Loaders value; } #endif}/// summary/// A shallow copy of the list of loaders currently managed by this XR Manager instance./// /summary/// remarks/// This property returns a read only list. Any changes made to the list itself will not affect the list/// used by this XR Manager instance. To mutate the list of loaders currently managed by this instance,/// use see crefTryAddLoader/, see crefTryRemoveLoader/, and/or see crefTrySetLoaders/./// /remarkspublic IReadOnlyListXRLoader activeLoaders m_Loaders;/// summary/// Read only boolean letting us know if initialization is completed. Because initialization is/// handled as a Coroutine, people taking advantage of the auto-lifecycle management of XRManager/// will need to wait for init to complete before checking for an ActiveLoader and calling StartSubsystems./// /summarypublic bool isInitializationComplete{get { return m_InitializationComplete; }}///summary/// Return the current singleton active loader instance.////summary[HideInInspector]public XRLoader activeLoader { get; private set; }/// summary/// Return the current active loader, cast to the requested type. Useful shortcut when you need/// to get the active loader as something less generic than XRLoader./// /summary////// typeparam nameTRequested type of the loader/typeparam////// returnsThe active loader as requested type, or null./returnspublic T ActiveLoaderAsT() where T : XRLoader{return activeLoader as T;}/// summary/// Iterate over the configured list of loaders and attempt to initialize each one. The first one/// that succeeds is set as the active loader and initialization immediately terminates.////// When complete see crefisInitializationComplete/ will be set to true. This will mark that it is safe to/// call other parts of the API. This does not guarantee that init successfully created a loader. For that/// you need to check that ActiveLoader is not null.////// Note that there can only be one active loader. Any attempt to initialize a new active loader with one/// already set will cause a warning to be logged and immediate exit of this function.////// This method is synchronous and on return all state should be immediately checkable.////// bIf manual initialization of XR is being done, this method can not be called before Start completes/// as it depends on graphics initialization within Unity completing./b/// /summarypublic void InitializeLoaderSync(){if (activeLoader ! null){Debug.LogWarning(XR Management has already initialized an active loader in this scene. Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.);return;}foreach (var loader in currentLoaders){if (loader ! null){if (CheckGraphicsAPICompatibility(loader) loader.Initialize()){activeLoader loader;m_InitializationComplete true;return;}}}activeLoader null;}/// summary/// Iterate over the configured list of loaders and attempt to initialize each one. The first one/// that succeeds is set as the active loader and initialization immediately terminates.////// When complete see crefisInitializationComplete/ will be set to true. This will mark that it is safe to/// call other parts of the API. This does not guarantee that init successfully created a loader. For that/// you need to check that ActiveLoader is not null.////// Note that there can only be one active loader. Any attempt to initialize a new active loader with one/// already set will cause a warning to be logged and immediate exit of this function.////// Iteration is done asynchronously and this method must be called within the context of a Coroutine.////// bIf manual initialization of XR is being done, this method can not be called before Start completes/// as it depends on graphics initialization within Unity completing./b/// /summary////// returnsEnumerator marking the next spot to continue execution at./returnspublic IEnumerator InitializeLoader(){if (activeLoader ! null){Debug.LogWarning(XR Management has already initialized an active loader in this scene. Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.);yield break;}foreach (var loader in currentLoaders){if (loader ! null){if (CheckGraphicsAPICompatibility(loader) loader.Initialize()){activeLoader loader;m_InitializationComplete true;yield break;}}yield return null;}activeLoader null;}/// summary/// Attempts to append the given loader to the list of loaders at the given index./// /summary/// param nameloader/// The see crefXRLoader/ to be added to this managers instance of loaders./// /param/// param nameindex/// The index at which the given see crefXRLoader/ should be added. If you set a negative or otherwise/// invalid index, the loader will be appended to the end of the list./// /param/// returns/// ctrue/c if the loader is not a duplicate and was added to the list successfully, cfalse/c/// otherwise./// /returns/// remarks/// This method behaves differently in the Editor and during runtime/Play mode. While your app runs in the Editor and not in/// Play mode, attempting to add an see crefXRLoader/ will always succeed and register that loaders type/// internally. Attempting to add a loader during runtime/Play mode will trigger a check to see whether a loader of/// that type was registered. If the check is successful, the loader is added. If not, the loader is not added and the method/// returns cfalse/c./// /remarkspublic bool TryAddLoader(XRLoader loader, int index -1){if (loader null || currentLoaders.Contains(loader))return false;#if UNITY_EDITORif (!EditorApplication.isPlaying !m_RegisteredLoaders.Contains(loader))m_RegisteredLoaders.Add(loader); #endifif (!m_RegisteredLoaders.Contains(loader))return false;if (index 0 || index currentLoaders.Count)currentLoaders.Add(loader);elsecurrentLoaders.Insert(index, loader);return true;}/// summary/// Attempts to remove the first instance of a given loader from the list of loaders./// /summary/// param nameloader/// The see crefXRLoader/ to be removed from this managers instance of loaders./// /param/// returns/// ctrue/c if the loader was successfully removed from the list, cfalse/c otherwise./// /returns/// remarks/// This method behaves differently in the Editor and during runtime/Play mode. During runtime/Play mode, the loader/// will be removed with no additional side effects if it is in the list managed by this instance. While in the/// Editor and not in Play mode, the loader will be removed if it exists and/// it will be unregistered from this instance and any attempts to add it during/// runtime/Play mode will fail. You can re-add the loader in the Editor while not in Play mode./// /remarkspublic bool TryRemoveLoader(XRLoader loader){var removedLoader true;if (currentLoaders.Contains(loader))removedLoader currentLoaders.Remove(loader);#if UNITY_EDITORif (!EditorApplication.isPlaying !currentLoaders.Contains(loader))m_RegisteredLoaders.Remove(loader); #endifreturn removedLoader;}/// summary/// Attempts to set the given loader list as the list of loaders managed by this instance./// /summary/// param namereorderedLoaders/// The list of see crefXRLoader/s to be managed by this manager instance./// /param/// returns/// ctrue/c if the loader list was set successfully, cfalse/c otherwise./// /returns/// remarks/// This method behaves differently in the Editor and during runtime/Play mode. While in the Editor and not in/// Play mode, any attempts to set the list of loaders will succeed without any additional checks. During/// runtime/Play mode, the new loader list will be validated against the registered see crefXRLoader/ types./// If any loaders exist in the list that were not registered at startup, the attempt will fail./// /remarkspublic bool TrySetLoaders(ListXRLoader reorderedLoaders){var originalLoaders new ListXRLoader(activeLoaders); #if UNITY_EDITORif (!EditorApplication.isPlaying){registeredLoaders.Clear();currentLoaders.Clear();foreach (var loader in reorderedLoaders){if (!TryAddLoader(loader)){TrySetLoaders(originalLoaders);return false;}}return true;} #endifcurrentLoaders.Clear();foreach (var loader in reorderedLoaders){if (!TryAddLoader(loader)){currentLoaders originalLoaders;return false;}}return true;}private bool CheckGraphicsAPICompatibility(XRLoader loader){GraphicsDeviceType deviceType SystemInfo.graphicsDeviceType;ListGraphicsDeviceType supportedDeviceTypes loader.GetSupportedGraphicsDeviceTypes(false);// To help with backward compatibility, if the compatibility list is empty we assume that it does not implement the GetSupportedGraphicsDeviceTypes method// Therefore we revert to the previous behavior of building or starting the loader regardless of gfx api settings.if (supportedDeviceTypes.Count 0 !supportedDeviceTypes.Contains(deviceType)){Debug.LogWarning(String.Format(The {0} does not support the initialized graphics device, {1}. Please change the preffered Graphics API in PlayerSettings. Attempting to start the next XR loader., loader.name, deviceType.ToString()));return false;}return true;}/// summary/// If there is an active loader, this will request the loader to start all the subsystems that it/// is managing.////// You must wait for see crefisInitializationComplete/ to be set to true prior to calling this API./// /summarypublic void StartSubsystems(){if (!m_InitializationComplete){Debug.LogWarning(Call to StartSubsystems without an initialized manager. Please make sure wait for initialization to complete before calling this API.);return;}if (activeLoader ! null){activeLoader.Start();}}/// summary/// If there is an active loader, this will request the loader to stop all the subsystems that it/// is managing.////// You must wait for see crefisInitializationComplete/ to be set to tru prior to calling this API./// /summarypublic void StopSubsystems(){if (!m_InitializationComplete){Debug.LogWarning(Call to StopSubsystems without an initialized manager. Please make sure wait for initialization to complete before calling this API.);return;}if (activeLoader ! null){activeLoader.Stop();}}/// summary/// If there is an active loader, this function will deinitialize it and remove the active loader instance from/// management. We will automatically call see crefStopSubsystems/ prior to deinitialization to make sure/// that things are cleaned up appropriately.////// You must wait for see crefisInitializationComplete/ to be set to tru prior to calling this API.////// Upon return see crefisInitializationComplete/ will be rest to false;/// /summarypublic void DeinitializeLoader(){if (!m_InitializationComplete){Debug.LogWarning(Call to DeinitializeLoader without an initialized manager. Please make sure wait for initialization to complete before calling this API.);return;}StopSubsystems();if (activeLoader ! null){activeLoader.Deinitialize();activeLoader null;}m_InitializationComplete false;}// Use this for initializationvoid Start(){if (automaticLoading automaticRunning){StartSubsystems();}}void OnDisable(){if (automaticLoading automaticRunning){StopSubsystems();}}void OnDestroy(){if (automaticLoading){DeinitializeLoader();}}// To modify the list of loaders internally use currentLoaders as it will return a list reference rather// than a shallow copy.// TODO davidmo 10/12/2020: remove this in next major version bump and make loaders internal.internal ListXRLoader currentLoaders{get { return m_Loaders; }set { m_Loaders value; }}// To modify the set of registered loaders use registeredLoaders as it will return a reference to the// hashset of loaders.internal HashSetXRLoader registeredLoaders{get { return m_RegisteredLoaders; }}} }事情变的有趣起来我们知道了这样的原理之后那鱼蛋我就想着尝试下在Runtime里动态切换行吧SteamVR场景切换到OpenVR Loader而XR场景切换到OpenXR代码如下。 using System.Collections.Generic; using Unity.XR.OpenVR; using UnityEngine; using UnityEngine.XR.Management; using UnityEngine.XR.OpenXR;namespace EgoGame {/// summary/// 该类有问题废弃了/// /summarypublic class AutoXRLoader:MonoBehaviour{public ListXRLoader xrLoaders;public ListXRLoader vrLoaders;public bool isXR;private void Awake(){SetLoader(isXR);}private void OnDestroy(){SetLoader(!isXR);}void SetLoader(bool xr){//不这样会频繁的退出loaderVR会没画面if (xr XRGeneralSettings.Instance.Manager.activeLoader is OpenXRLoader){return;}if (!xr XRGeneralSettings.Instance.Manager.activeLoader is OpenVRLoader){return;}var loaders xr ? xrLoaders : vrLoaders;Debug.Log(切换Loader xrXRGeneralSettings.Instance.Manager.activeLoader);XRGeneralSettings.Instance.Manager.DeinitializeLoader();XRGeneralSettings.Instance.Manager.TrySetLoaders(loaders);XRGeneralSettings.Instance.Manager.InitializeLoaderSync();XRGeneralSettings.Instance.Manager.StartSubsystems();}} } 果然奏效了XR场景能在头盔里识别并运行了手柄也能控制。但是切到SteamVR场景就出现了问题Steam VR SDK报错了报错提示有另一个应用在使用SteamVR。 最后的结果就是没法实现动态切换XR或VR如果看到此处的人有办法请告诉我我尝试了两天用了各种办法都没法做到。 最后推荐大家开发VR应用不要直接用SteamVR SDK或XR SDK或Oculus SDK开发而是用那些集成的插件如VR Interaction Framework、VRTK等这样在多个VR设备也能快速部署。