Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TrackedPoseDriver.cs 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. using System;
  2. using UnityEngine.InputSystem.LowLevel;
  3. namespace UnityEngine.InputSystem.XR
  4. {
  5. /// <summary>
  6. /// The <see cref="TrackedPoseDriver"/> component applies the current pose value of a tracked device
  7. /// to the <see cref="Transform"/> of the <see cref="GameObject"/>.
  8. /// <see cref="TrackedPoseDriver"/> can track multiple types of devices including XR HMDs, controllers, and remotes.
  9. /// </summary>
  10. /// <remarks>
  11. /// For <see cref="positionInput"/> and <see cref="rotationInput"/>, if an action is directly defined
  12. /// in the <see cref="InputActionProperty"/>, as opposed to a reference to an action externally defined
  13. /// in an <see cref="InputActionAsset"/>, the action will automatically be enabled and disabled by this
  14. /// behavior during <see cref="OnEnable"/> and <see cref="OnDisable"/>. The enabled state for actions
  15. /// externally defined must be managed externally from this behavior.
  16. /// </remarks>
  17. [Serializable]
  18. [AddComponentMenu("XR/Tracked Pose Driver (Input System)")]
  19. public class TrackedPoseDriver : MonoBehaviour, ISerializationCallbackReceiver
  20. {
  21. /// <summary>
  22. /// Options for which <see cref="Transform"/> properties to update.
  23. /// </summary>
  24. /// <seealso cref="trackingType"/>
  25. public enum TrackingType
  26. {
  27. /// <summary>
  28. /// Update both rotation and position.
  29. /// </summary>
  30. RotationAndPosition,
  31. /// <summary>
  32. /// Update rotation only.
  33. /// </summary>
  34. RotationOnly,
  35. /// <summary>
  36. /// Update position only.
  37. /// </summary>
  38. PositionOnly,
  39. }
  40. /// <summary>
  41. /// These bit flags correspond with <c>UnityEngine.XR.InputTrackingState</c>
  42. /// but that enum is not used to avoid adding a dependency to the XR module.
  43. /// Only the Position and Rotation flags are used by this class, so velocity and acceleration flags are not duplicated here.
  44. /// </summary>
  45. [Flags]
  46. enum TrackingStates
  47. {
  48. /// <summary>
  49. /// Position and rotation are not valid.
  50. /// </summary>
  51. None,
  52. /// <summary>
  53. /// Position is valid.
  54. /// See <c>InputTrackingState.Position</c>.
  55. /// </summary>
  56. Position = 1 << 0,
  57. /// <summary>
  58. /// Rotation is valid.
  59. /// See <c>InputTrackingState.Rotation</c>.
  60. /// </summary>
  61. Rotation = 1 << 1,
  62. }
  63. [SerializeField, Tooltip("Which Transform properties to update.")]
  64. TrackingType m_TrackingType;
  65. /// <summary>
  66. /// The tracking type being used by the Tracked Pose Driver
  67. /// to control which <see cref="Transform"/> properties to update.
  68. /// </summary>
  69. /// <seealso cref="TrackingType"/>
  70. public TrackingType trackingType
  71. {
  72. get => m_TrackingType;
  73. set => m_TrackingType = value;
  74. }
  75. /// <summary>
  76. /// Options for which phases of the player loop will update <see cref="Transform"/> properties.
  77. /// </summary>
  78. /// <seealso cref="updateType"/>
  79. /// <seealso cref="InputSystem.onAfterUpdate"/>
  80. public enum UpdateType
  81. {
  82. /// <summary>
  83. /// Update after the Input System has completed an update and right before rendering.
  84. /// This is the recommended and default option to minimize lag for XR tracked devices.
  85. /// </summary>
  86. /// <seealso cref="InputUpdateType.BeforeRender"/>
  87. UpdateAndBeforeRender,
  88. /// <summary>
  89. /// Update after the Input System has completed an update except right before rendering.
  90. /// </summary>
  91. /// <remarks>
  92. /// This may be dynamic update, fixed update, or a manual update depending on the Update Mode
  93. /// project setting for Input System.
  94. /// </remarks>
  95. Update,
  96. /// <summary>
  97. /// Update after the Input System has completed an update right before rendering.
  98. /// </summary>
  99. /// <remarks>
  100. /// Note that this update mode may not trigger if there are no XR devices added which use before render timing.
  101. /// </remarks>
  102. /// <seealso cref="InputUpdateType.BeforeRender"/>
  103. /// <seealso cref="InputDevice.updateBeforeRender"/>
  104. BeforeRender,
  105. }
  106. [SerializeField, Tooltip("Updates the Transform properties after these phases of Input System event processing.")]
  107. UpdateType m_UpdateType = UpdateType.UpdateAndBeforeRender;
  108. /// <summary>
  109. /// The update type being used by the Tracked Pose Driver
  110. /// to control which phases of the player loop will update <see cref="Transform"/> properties.
  111. /// </summary>
  112. /// <seealso cref="UpdateType"/>
  113. public UpdateType updateType
  114. {
  115. get => m_UpdateType;
  116. set => m_UpdateType = value;
  117. }
  118. [SerializeField, Tooltip("Ignore Tracking State and always treat the input pose as valid.")]
  119. bool m_IgnoreTrackingState;
  120. /// <summary>
  121. /// Ignore tracking state and always treat the input pose as valid when updating the <see cref="Transform"/> properties.
  122. /// The recommended value is <see langword="false"/> so the tracking state input is used.
  123. /// </summary>
  124. /// <seealso cref="trackingStateInput"/>
  125. public bool ignoreTrackingState
  126. {
  127. get => m_IgnoreTrackingState;
  128. set => m_IgnoreTrackingState = value;
  129. }
  130. [SerializeField, Tooltip("The input action to read the position value of a tracked device. Must be a Vector 3 control type.")]
  131. InputActionProperty m_PositionInput;
  132. /// <summary>
  133. /// The input action to read the position value of a tracked device.
  134. /// Must support reading a value of type <see cref="Vector3"/>.
  135. /// </summary>
  136. /// <seealso cref="rotationInput"/>
  137. public InputActionProperty positionInput
  138. {
  139. get => m_PositionInput;
  140. set
  141. {
  142. if (Application.isPlaying)
  143. UnbindPosition();
  144. m_PositionInput = value;
  145. if (Application.isPlaying && isActiveAndEnabled)
  146. BindPosition();
  147. }
  148. }
  149. [SerializeField, Tooltip("The input action to read the rotation value of a tracked device. Must be a Quaternion control type.")]
  150. InputActionProperty m_RotationInput;
  151. /// <summary>
  152. /// The input action to read the rotation value of a tracked device.
  153. /// Must support reading a value of type <see cref="Quaternion"/>.
  154. /// </summary>
  155. /// <seealso cref="positionInput"/>
  156. public InputActionProperty rotationInput
  157. {
  158. get => m_RotationInput;
  159. set
  160. {
  161. if (Application.isPlaying)
  162. UnbindRotation();
  163. m_RotationInput = value;
  164. if (Application.isPlaying && isActiveAndEnabled)
  165. BindRotation();
  166. }
  167. }
  168. [SerializeField, Tooltip("The input action to read the tracking state value of a tracked device. Identifies if position and rotation have valid data. Must be an Integer control type.")]
  169. InputActionProperty m_TrackingStateInput;
  170. /// <summary>
  171. /// The input action to read the tracking state value of a tracked device.
  172. /// Identifies if position and rotation have valid data.
  173. /// Must support reading a value of type <see cref="int"/>.
  174. /// </summary>
  175. /// <remarks>
  176. /// See [InputTrackingState](xref:UnityEngine.XR.InputTrackingState) enum for values the input action represents.
  177. /// <list type="bullet">
  178. /// <item>
  179. /// <term>[InputTrackingState.None](xref:UnityEngine.XR.InputTrackingState.None) (0)</term>
  180. /// <description>to indicate neither position nor rotation is valid.</description>
  181. /// </item>
  182. /// <item>
  183. /// <term>[InputTrackingState.Position](xref:UnityEngine.XR.InputTrackingState.Position) (1)</term>
  184. /// <description>to indicate position is valid.</description>
  185. /// </item>
  186. /// <item>
  187. /// <term>[InputTrackingState.Rotation](xref:UnityEngine.XR.InputTrackingState.Rotation) (2)</term>
  188. /// <description>to indicate rotation is valid.</description>
  189. /// </item>
  190. /// <item>
  191. /// <term>[InputTrackingState.Position](xref:UnityEngine.XR.InputTrackingState.Position) <c>|</c> [InputTrackingState.Rotation](xref:UnityEngine.XR.InputTrackingState.Rotation) (3)</term>
  192. /// <description>to indicate position and rotation is valid.</description>
  193. /// </item>
  194. /// </list>
  195. /// </remarks>
  196. /// <seealso cref="ignoreTrackingState"/>
  197. public InputActionProperty trackingStateInput
  198. {
  199. get => m_TrackingStateInput;
  200. set
  201. {
  202. if (Application.isPlaying)
  203. UnbindTrackingState();
  204. m_TrackingStateInput = value;
  205. if (Application.isPlaying && isActiveAndEnabled)
  206. BindTrackingState();
  207. }
  208. }
  209. Vector3 m_CurrentPosition = Vector3.zero;
  210. Quaternion m_CurrentRotation = Quaternion.identity;
  211. TrackingStates m_CurrentTrackingState = TrackingStates.Position | TrackingStates.Rotation;
  212. bool m_RotationBound;
  213. bool m_PositionBound;
  214. bool m_TrackingStateBound;
  215. bool m_IsFirstUpdate = true;
  216. void BindActions()
  217. {
  218. BindPosition();
  219. BindRotation();
  220. BindTrackingState();
  221. }
  222. void UnbindActions()
  223. {
  224. UnbindPosition();
  225. UnbindRotation();
  226. UnbindTrackingState();
  227. }
  228. void BindPosition()
  229. {
  230. if (m_PositionBound)
  231. return;
  232. var action = m_PositionInput.action;
  233. if (action == null)
  234. return;
  235. action.performed += OnPositionPerformed;
  236. action.canceled += OnPositionCanceled;
  237. m_PositionBound = true;
  238. if (m_PositionInput.reference == null)
  239. {
  240. action.Rename($"{gameObject.name} - TPD - Position");
  241. action.Enable();
  242. }
  243. }
  244. void BindRotation()
  245. {
  246. if (m_RotationBound)
  247. return;
  248. var action = m_RotationInput.action;
  249. if (action == null)
  250. return;
  251. action.performed += OnRotationPerformed;
  252. action.canceled += OnRotationCanceled;
  253. m_RotationBound = true;
  254. if (m_RotationInput.reference == null)
  255. {
  256. action.Rename($"{gameObject.name} - TPD - Rotation");
  257. action.Enable();
  258. }
  259. }
  260. void BindTrackingState()
  261. {
  262. if (m_TrackingStateBound)
  263. return;
  264. var action = m_TrackingStateInput.action;
  265. if (action == null)
  266. return;
  267. action.performed += OnTrackingStatePerformed;
  268. action.canceled += OnTrackingStateCanceled;
  269. m_TrackingStateBound = true;
  270. if (m_TrackingStateInput.reference == null)
  271. {
  272. action.Rename($"{gameObject.name} - TPD - Tracking State");
  273. action.Enable();
  274. }
  275. }
  276. void UnbindPosition()
  277. {
  278. if (!m_PositionBound)
  279. return;
  280. var action = m_PositionInput.action;
  281. if (action == null)
  282. return;
  283. if (m_PositionInput.reference == null)
  284. action.Disable();
  285. action.performed -= OnPositionPerformed;
  286. action.canceled -= OnPositionCanceled;
  287. m_PositionBound = false;
  288. }
  289. void UnbindRotation()
  290. {
  291. if (!m_RotationBound)
  292. return;
  293. var action = m_RotationInput.action;
  294. if (action == null)
  295. return;
  296. if (m_RotationInput.reference == null)
  297. action.Disable();
  298. action.performed -= OnRotationPerformed;
  299. action.canceled -= OnRotationCanceled;
  300. m_RotationBound = false;
  301. }
  302. void UnbindTrackingState()
  303. {
  304. if (!m_TrackingStateBound)
  305. return;
  306. var action = m_TrackingStateInput.action;
  307. if (action == null)
  308. return;
  309. if (m_TrackingStateInput.reference == null)
  310. action.Disable();
  311. action.performed -= OnTrackingStatePerformed;
  312. action.canceled -= OnTrackingStateCanceled;
  313. m_TrackingStateBound = false;
  314. }
  315. void OnPositionPerformed(InputAction.CallbackContext context)
  316. {
  317. m_CurrentPosition = context.ReadValue<Vector3>();
  318. }
  319. void OnPositionCanceled(InputAction.CallbackContext context)
  320. {
  321. m_CurrentPosition = Vector3.zero;
  322. }
  323. void OnRotationPerformed(InputAction.CallbackContext context)
  324. {
  325. m_CurrentRotation = context.ReadValue<Quaternion>();
  326. }
  327. void OnRotationCanceled(InputAction.CallbackContext context)
  328. {
  329. m_CurrentRotation = Quaternion.identity;
  330. }
  331. void OnTrackingStatePerformed(InputAction.CallbackContext context)
  332. {
  333. m_CurrentTrackingState = (TrackingStates)context.ReadValue<int>();
  334. }
  335. void OnTrackingStateCanceled(InputAction.CallbackContext context)
  336. {
  337. m_CurrentTrackingState = TrackingStates.None;
  338. }
  339. /// <summary>
  340. /// This function is called when the user hits the Reset button in the Inspector's context menu
  341. /// or when adding the component the first time. This function is only called in editor mode.
  342. /// </summary>
  343. protected void Reset()
  344. {
  345. m_PositionInput = new InputActionProperty(new InputAction("Position", expectedControlType: "Vector3"));
  346. m_RotationInput = new InputActionProperty(new InputAction("Rotation", expectedControlType: "Quaternion"));
  347. m_TrackingStateInput = new InputActionProperty(new InputAction("Tracking State", expectedControlType: "Integer"));
  348. }
  349. /// <summary>
  350. /// This function is called when the script instance is being loaded.
  351. /// </summary>
  352. protected virtual void Awake()
  353. {
  354. #if UNITY_INPUT_SYSTEM_ENABLE_VR && ENABLE_VR
  355. if (HasStereoCamera(out var cameraComponent))
  356. {
  357. UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(cameraComponent, true);
  358. }
  359. #endif
  360. }
  361. /// <summary>
  362. /// This function is called when the object becomes enabled and active.
  363. /// </summary>
  364. protected void OnEnable()
  365. {
  366. InputSystem.onAfterUpdate += UpdateCallback;
  367. BindActions();
  368. // Read current input values when becoming enabled,
  369. // but wait until after the input update so the input is read at a consistent time
  370. m_IsFirstUpdate = true;
  371. }
  372. /// <summary>
  373. /// This function is called when the object becomes disabled or inactive.
  374. /// </summary>
  375. protected void OnDisable()
  376. {
  377. UnbindActions();
  378. InputSystem.onAfterUpdate -= UpdateCallback;
  379. }
  380. /// <summary>
  381. /// This function is called when the <see cref="MonoBehaviour"/> will be destroyed.
  382. /// </summary>
  383. protected virtual void OnDestroy()
  384. {
  385. #if UNITY_INPUT_SYSTEM_ENABLE_VR && ENABLE_VR
  386. if (HasStereoCamera(out var cameraComponent))
  387. {
  388. UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(cameraComponent, false);
  389. }
  390. #endif
  391. }
  392. /// <summary>
  393. /// The callback method called after the Input System has completed an update and processed all pending events.
  394. /// </summary>
  395. /// <seealso cref="InputSystem.onAfterUpdate"/>
  396. protected void UpdateCallback()
  397. {
  398. if (m_IsFirstUpdate)
  399. {
  400. // Update current input values if this is the first update since becoming enabled
  401. // since the performed callbacks may not have been executed
  402. if (m_PositionInput.action != null)
  403. m_CurrentPosition = m_PositionInput.action.ReadValue<Vector3>();
  404. if (m_RotationInput.action != null)
  405. m_CurrentRotation = m_RotationInput.action.ReadValue<Quaternion>();
  406. ReadTrackingState();
  407. m_IsFirstUpdate = false;
  408. }
  409. if (InputState.currentUpdateType == InputUpdateType.BeforeRender)
  410. OnBeforeRender();
  411. else
  412. OnUpdate();
  413. }
  414. void ReadTrackingState()
  415. {
  416. var trackingStateAction = m_TrackingStateInput.action;
  417. if (trackingStateAction != null && !trackingStateAction.enabled)
  418. {
  419. // Treat a disabled action as the default None value for the ReadValue call
  420. m_CurrentTrackingState = TrackingStates.None;
  421. return;
  422. }
  423. if (trackingStateAction == null || trackingStateAction.m_BindingsCount == 0)
  424. {
  425. // Treat an Input Action Reference with no reference the same as
  426. // an enabled Input Action with no authored bindings, and allow driving the Transform pose.
  427. m_CurrentTrackingState = TrackingStates.Position | TrackingStates.Rotation;
  428. return;
  429. }
  430. // Grab state.
  431. var actionMap = trackingStateAction.GetOrCreateActionMap();
  432. actionMap.ResolveBindingsIfNecessary();
  433. var state = actionMap.m_State;
  434. // Get list of resolved controls to determine if a device actually has tracking state.
  435. var hasResolvedControl = false;
  436. if (state != null)
  437. {
  438. var actionIndex = trackingStateAction.m_ActionIndexInState;
  439. var totalBindingCount = state.totalBindingCount;
  440. for (var i = 0; i < totalBindingCount; ++i)
  441. {
  442. unsafe
  443. {
  444. ref var bindingState = ref state.bindingStates[i];
  445. if (bindingState.actionIndex != actionIndex)
  446. continue;
  447. if (bindingState.isComposite)
  448. continue;
  449. if (bindingState.controlCount > 0)
  450. {
  451. hasResolvedControl = true;
  452. break;
  453. }
  454. }
  455. }
  456. }
  457. // Retain the current value if there is no resolved binding.
  458. // Since the field initializes to allowing position and rotation,
  459. // this allows for driving the Transform pose always when the device
  460. // doesn't support reporting the tracking state.
  461. if (hasResolvedControl)
  462. m_CurrentTrackingState = (TrackingStates)trackingStateAction.ReadValue<int>();
  463. }
  464. /// <summary>
  465. /// This method is called after the Input System has completed an update and processed all pending events
  466. /// when the type of update is not <see cref="InputUpdateType.BeforeRender"/>.
  467. /// </summary>
  468. protected virtual void OnUpdate()
  469. {
  470. if (m_UpdateType == UpdateType.Update ||
  471. m_UpdateType == UpdateType.UpdateAndBeforeRender)
  472. {
  473. PerformUpdate();
  474. }
  475. }
  476. /// <summary>
  477. /// This method is called after the Input System has completed an update and processed all pending events
  478. /// when the type of update is <see cref="InputUpdateType.BeforeRender"/>.
  479. /// </summary>
  480. protected virtual void OnBeforeRender()
  481. {
  482. if (m_UpdateType == UpdateType.BeforeRender ||
  483. m_UpdateType == UpdateType.UpdateAndBeforeRender)
  484. {
  485. PerformUpdate();
  486. }
  487. }
  488. /// <summary>
  489. /// Updates <see cref="Transform"/> properties with the current input pose values that have been read,
  490. /// constrained by tracking type and tracking state.
  491. /// </summary>
  492. /// <seealso cref="SetLocalTransform"/>
  493. protected virtual void PerformUpdate()
  494. {
  495. SetLocalTransform(m_CurrentPosition, m_CurrentRotation);
  496. }
  497. /// <summary>
  498. /// Updates <see cref="Transform"/> properties, constrained by tracking type and tracking state.
  499. /// </summary>
  500. /// <param name="newPosition">The new local position to possibly set.</param>
  501. /// <param name="newRotation">The new local rotation to possibly set.</param>
  502. protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRotation)
  503. {
  504. var positionValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Position) != 0;
  505. var rotationValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Rotation) != 0;
  506. #if HAS_SET_LOCAL_POSITION_AND_ROTATION
  507. if (m_TrackingType == TrackingType.RotationAndPosition && rotationValid && positionValid)
  508. {
  509. transform.SetLocalPositionAndRotation(newPosition, newRotation);
  510. return;
  511. }
  512. #endif
  513. if (rotationValid &&
  514. (m_TrackingType == TrackingType.RotationAndPosition ||
  515. m_TrackingType == TrackingType.RotationOnly))
  516. {
  517. transform.localRotation = newRotation;
  518. }
  519. if (positionValid &&
  520. (m_TrackingType == TrackingType.RotationAndPosition ||
  521. m_TrackingType == TrackingType.PositionOnly))
  522. {
  523. transform.localPosition = newPosition;
  524. }
  525. }
  526. bool HasStereoCamera(out Camera cameraComponent)
  527. {
  528. return TryGetComponent(out cameraComponent) && cameraComponent.stereoEnabled;
  529. }
  530. #region DEPRECATED
  531. // Disable warnings that these fields are never assigned to. They are set during Unity deserialization and migrated.
  532. // ReSharper disable UnassignedField.Local
  533. #pragma warning disable 0649
  534. [Obsolete]
  535. [SerializeField, HideInInspector]
  536. InputAction m_PositionAction;
  537. /// <summary>
  538. /// (Deprecated) The action to read the position value of a tracked device.
  539. /// Must support reading a value of type <see cref="Vector3"/>.
  540. /// </summary>
  541. /// <seealso cref="positionInput"/>
  542. public InputAction positionAction
  543. {
  544. get => m_PositionInput.action;
  545. set => positionInput = new InputActionProperty(value);
  546. }
  547. [Obsolete]
  548. [SerializeField, HideInInspector]
  549. InputAction m_RotationAction;
  550. /// <summary>
  551. /// (Deprecated) The action to read the rotation value of a tracked device.
  552. /// Must support reading a value of type <see cref="Quaternion"/>.
  553. /// </summary>
  554. /// <seealso cref="rotationInput"/>
  555. public InputAction rotationAction
  556. {
  557. get => m_RotationInput.action;
  558. set => rotationInput = new InputActionProperty(value);
  559. }
  560. #pragma warning restore 0649
  561. // ReSharper restore UnassignedField.Local
  562. /// <inheritdoc />
  563. void ISerializationCallbackReceiver.OnBeforeSerialize()
  564. {
  565. }
  566. /// <inheritdoc />
  567. void ISerializationCallbackReceiver.OnAfterDeserialize()
  568. {
  569. #pragma warning disable 0612 // Type or member is obsolete -- Deprecated fields are migrated to new properties.
  570. #pragma warning disable UNT0029 // Pattern matching with null on Unity objects -- Using true null is intentional, not operator== evaluation.
  571. // We're checking for true null here since we don't want to migrate if the new field is already being used, even if the reference is missing.
  572. // Migrate the old fields to the new properties added in Input System 1.1.0-pre.6.
  573. if (m_PositionInput.serializedReference is null && m_PositionInput.serializedAction is null && !(m_PositionAction is null))
  574. m_PositionInput = new InputActionProperty(m_PositionAction);
  575. if (m_RotationInput.serializedReference is null && m_RotationInput.serializedAction is null && !(m_RotationAction is null))
  576. m_RotationInput = new InputActionProperty(m_RotationAction);
  577. #pragma warning restore UNT0029
  578. #pragma warning restore 0612
  579. }
  580. #endregion
  581. }
  582. }