diff --git a/ZeroPacientVR/Assets/HurricaneVR/Documentation/ReleaseNotes.txt b/ZeroPacientVR/Assets/HurricaneVR/Documentation/ReleaseNotes.txt index 5c3b4017..830169e7 100644 --- a/ZeroPacientVR/Assets/HurricaneVR/Documentation/ReleaseNotes.txt +++ b/ZeroPacientVR/Assets/HurricaneVR/Documentation/ReleaseNotes.txt @@ -1,3 +1,106 @@ + +2.9.1f + +Added Pico device detection for controller offsets. +Fixed HVRStringSocketFilter / HVRStringSocketable filtering pair. +Fixed shoulder socket not working when moving forward. + + +2.9.1e +HVRGrabbable: new overridable function CanHandGrab for grab filtering. +HVRHandGrabFilter - abstract base class for modular hand grab filtering +HVRGrabHandFilter - new component for hvrgrabbable to limit which hand can grab +Example scene updated for grab hand filter + +2.9.1 + +Fixed bug where the grab joint might end up on the wrong game object if the grabbable was a child of the rigidbody. +Fixed player controller to take into account the angle of the surface the player is standing on. +Fixed bug where child grabbables could be grabbed if their MasterGrabbable was socketed. +Added backpack rigs to hexabody integration. +Fix Oculus and WMR menu button bindings for OpenXR +Fix HVRCockingHandle to handle initial grab offset better + +Hand Strength Updates: + JointSettings on the hand and grabbable components are now deprecated, they will continue to work but will be removed in a future update. + PDStrength scriptable object is the replacement containing only the fields that are pertinent to the PD Controlled hands. + Fields that reference an existing PDStrength asset will display the editor in place for quick editing. + The following fields are added to replace the old ones: + HVRJointHand.Strength + HVRHexaBodyHands.Strength|OneHandedClimbStrength|TwoHandedClimbStrength + HVRGrabbable.OneHandStrength|TwoHandStrength + Included rig and hand prefabs are updated. + +Teleporter: Momentum is now maintained for the hands and held objects when teleporting. + Physics hands now account for teleporter jumping large distances. + +HVRSocketLink: + Permanently links a grabbable to a socket with optional return time lerping. + Replaces the now deprecated grabbable fields StartingSocket/LinkStartingSocket. + Filter setup is not required as the socket will only accept the linked object. + Example scene updated with socket example. Backpack on rig prefab updated. + +HVRSocket: all rb properties restored when RemoveRigidbody mode is used. +HVRPlayerInputs: ForceGrabber activated options updated with GripAndTrigger, Trigger, GripOrTrigger. +HVRHandImpactHaptics: MaxForce used in haptic amplitude calculation will default to the hand's max force value. +HVRGunBase: added hit collider, rigidbody, and distance to the arguments passed to the Hit event. +HVRStringSocketFilter and HVRStringSocketable updated to hash it's string value for performance. +HVRPlayerController: + - Added GroundedRadiusFactor which will multiply with the player capsules radius for the grounded sphere cast check. + - Horizontal ground movement will take into consideration the angle of the ground the player is on. + + + +2.9 + +Fixed grab indicators showing up even if they were marked disabled on the HVRGrabbable. +Fixed issue where CockingHandle would not lock forward if the controller was too far forward of the grab point. + +Added HVRPoseZone: Uses a provided HVRHandPoser to pose the hand when the hand enters the overlap zone. + Demo KeyPad updated with a pose zone example. +HVRSocket: New 'PoseTag' field which links with HVRSocketable Poses field for saving orientation when socketed. +HVRSocketable: New Poses field with inspector interface to help save orientations for different socket types. +HVRGunBase: Added Hit event which passes the gun, hitpoint, normal, and direction variables. +HVRHandAnimator: Added 'HandOverride' transform field, allows HVRPosableHand component to be on a different component. VRIK IK targets is one example. +Bow: Fixed hand collision being re-enabled to early with the arrow. +Hand Prefabs: Added trigger collider with HVRHandTrigger component for easy hand detection by other components (HVRPoseZone). +Example Shotgun: modified two hand hold strengths to prevent forehand from moving the shotgun backward to easily. + +2.8.7-2.8.8 + +Fixed hands ignoring collision with each other on the tech demo rig. +Fixed knuckles controllers grip hand animation when using OpenXR. +Fixed physics door not checking if second handle exists. +Fixed socketable throwing null error if instantiated and socketed in the same frame. +Fixed Camera Rig ignoring debug setting for up/down arrow if only the new input system was enabled. + +Removed RemainsKinematic from HVRGrabbable and snapshotting/restoring of IsKinematic during the grab procedure. Users should use + grabbed and released events for this from now on for full control of this field without framework interference. + +Auto Posing in editor mode randomly has issues when colliders are attached to a rigidbody, the hand poser editor will warn users of this now. + +2.8.6 + +Fixed wheel collider line of sight check and dynamic pose +Fixed bug where force pull would not re-enable collision with the hand if dropped before it reached the hand. +Fixed IsBeingForcedGrabbed not being set to false on a successfull force pull to the hand. +Fixed HVRPhysicsDoor joint anchor not being set to zero sometimes +Fixed null coroutine error on HVRGrabbable if object was disabled prior to being released. +Fixed obsolete api call in hand poser editor in 2021.2 and up. + +HVRPhysicsDoor upgraded to allow two door handles. Example scene swinging door updated with two separate handles. Web Docs updated. +Custom Hand Setup Wizard completed with tutorial in the web docs. +Virtualized HVRUIPointer methods. +Hand Posing now only works in scene view, prefab mode has issues when posing, a warning will display to alert the user. +Added new demo scene showing how to use hand animation parameters - 'scene_hand_squeeze' +Added commentary and tooltips to several helper components that were missing them. + +2.8.5 + +Fixed an issue where socketed objects would scale differently based on it's rotation prior to being socketed due to AABB sizing. +Fixed trigger colliders being deleted on the ClonedHandModel process. +CloneHandModel defaulted to false on included hand prefabs as ParentHandModel is defaulted to false on new grabbable objects. + 2.8.4 Fixed an issue with the version update check logic that was refreshing the asset database after compiles. diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/CustomContexts.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/CustomContexts.cs new file mode 100644 index 00000000..0b919c9a --- /dev/null +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/CustomContexts.cs @@ -0,0 +1,55 @@ +using HurricaneVR.Framework.Core.ScriptableObjects; +using HurricaneVR.Framework.Core.Utils; +using UnityEditor; +using UnityEngine; + +namespace HurricaneVR.Editor +{ + public class CustomContexts + { + [MenuItem("Assets/HVR/Convert to Strength", false, 1)] + private static void StrengthConvert(MenuCommand command) + { + foreach (var o in Selection.objects) + { + var path = AssetDatabase.GetAssetPath(o); + var js = AssetDatabase.LoadAssetAtPath(path); + if (!js) + continue; + + var fileName = path.Replace(".asset", ""); + fileName += "_Strength.asset"; + + var s = AssetDatabase.LoadAssetAtPath(fileName); + if (!s) + { + s = ScriptableObject.CreateInstance(); + } + + s.Mode = js.ApplyMode; + s.Spring = js.XDrive.Spring; + s.Damper = js.XDrive.Damper; + s.MaxForce = js.XDrive.MaxForce; + s.TorqueSpring = js.SlerpDrive.Spring; + s.TorqueDamper = js.SlerpDrive.Damper; + s.MaxTorque = js.SlerpDrive.MaxForce; + + AssetUtils.CreateOrReplaceAsset(s, fileName); + } + } + + [MenuItem("Assets/HVR/Convert to Strength", true, 1)] + private static bool StrengthConvertValidation() + { + foreach (var o in Selection.objects) + { + var path = AssetDatabase.GetAssetPath(o); + var js = AssetDatabase.LoadAssetAtPath(path); + if (!js) + return false; + } + + return Selection.objects.Length > 0; + } + } +} \ No newline at end of file diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/CustomContexts.cs.meta b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/CustomContexts.cs.meta new file mode 100644 index 00000000..201e850e --- /dev/null +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/CustomContexts.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e2d14f6a173045b08af8717e276df756 +timeCreated: 1666239275 \ No newline at end of file diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetDrawer.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetDrawer.cs new file mode 100644 index 00000000..b6f095b3 --- /dev/null +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetDrawer.cs @@ -0,0 +1,49 @@ +using HurricaneVR.Framework.Core.Utils; +using UnityEditor; +using UnityEngine; + +namespace HurricaneVR.Editor +{ + [CustomPropertyDrawer(typeof(EmbeddedAttribute), true)] + public class EmbeddedAssetDrawer : PropertyDrawer + { + private EmbeddeAssetEditor _editor; + + public EmbeddeAssetEditor Editor + { + get + { + if (_editor == null) + _editor = new EmbeddeAssetEditor(); + return _editor; + } + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + var a = attribute as EmbeddedAttribute; + + Editor.DrawEditorCombo(position, fieldInfo.FieldType, label, property, $"Save {property.displayName}.", $"{property.displayName.Replace(" ", "_")}", "asset", string.Empty); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + if (!property.isExpanded || property.objectReferenceValue == null) + { + return EditorGUIUtility.singleLineHeight; + } + + float height = base.GetPropertyHeight(property, label) + EditorGUIUtility.singleLineHeight; + var so = new SerializedObject(property.objectReferenceValue); + var prop = so.GetIterator(); + prop.NextVisible(true); + while (prop.NextVisible(true)) + { + if (prop.name == "m_Script") + continue; + height += EditorGUIUtility.singleLineHeight; + } + return height * 1.2f; + } + } +} \ No newline at end of file diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetDrawer.cs.meta b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetDrawer.cs.meta new file mode 100644 index 00000000..4ce5beb8 --- /dev/null +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d3003c99effe439d9d06c4e9334443ba +timeCreated: 1666146629 \ No newline at end of file diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetEditor.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetEditor.cs new file mode 100644 index 00000000..17f43977 --- /dev/null +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetEditor.cs @@ -0,0 +1,181 @@ +using System; +using System.Linq; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEditor.VersionControl; +using UnityEngine; +using UnityEngine.UIElements; + +namespace HurricaneVR.Editor +{ + /// + /// Helper for drawing embedded asset editors + /// + public class EmbeddeAssetEditor + { + /// + /// Free the resources in OnDisable() + /// + public void OnDisable() + { + DestroyEditor(); + } + + private readonly GUIContent m_CreateButtonGUIContent = new GUIContent("Create Asset", "Create new asset."); + + UnityEditor.Editor m_Editor = null; + const int kIndentOffset = 3; + private Type _type; + + public void DrawEditorCombo(Rect position, Type type, GUIContent label, SerializedProperty property, string title, string defaultName, string extension, string message) + { + _type = type; + DrawEditorCombo(position, property, title, defaultName, extension, message, false); + } + + /// + /// Call this from OnInspectorGUI. Will draw the asset reference field, and + /// the embedded editor, or a Create Asset button, if no asset is set. + /// + private void DrawEditorCombo(Rect position, SerializedProperty property, + string title, string defaultName, string extension, string message, + bool indent) + { + UpdateEditor(property); + if (!m_Editor) + { + AssetFieldWithCreateButton(position, property, title, defaultName, extension, message); + return; + } + + var rect = position; + var propRect = rect; + propRect.height = EditorGUIUtility.singleLineHeight; + EditorGUI.BeginChangeCheck(); + EditorGUI.PropertyField(propRect, property); + + if (EditorGUI.EndChangeCheck()) + { + property.serializedObject.ApplyModifiedProperties(); + UpdateEditor(property); + } + + if (m_Editor) + { + Rect foldoutRect = new Rect(rect.x - kIndentOffset, rect.y, rect.width + kIndentOffset, EditorGUIUtility.singleLineHeight); + property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none, true); + + bool canEditAsset = AssetDatabase.IsOpenForEdit(m_Editor.target, StatusQueryOptions.UseCachedIfPossible); + GUI.enabled = canEditAsset; + if (property.isExpanded) + { + position.y += EditorGUIUtility.singleLineHeight; + var box = position; + box.height *= .9f; + EditorGUI.HelpBox(box, "CTRL+S to persist asset changes.", MessageType.None); + position.y += EditorGUIUtility.singleLineHeight; + EditorGUI.BeginChangeCheck(); + var so = new SerializedObject(property.objectReferenceValue); + var prop = so.GetIterator(); + + while (prop.NextVisible(true)) + { + if (prop.name == "m_Script") + continue; + position.height = EditorGUIUtility.singleLineHeight; + EditorGUI.PropertyField(position, prop); + position.y += EditorGUIUtility.singleLineHeight; + } + + if (EditorGUI.EndChangeCheck()) + { + so.ApplyModifiedProperties(); + } + } + + GUI.enabled = true; + if (m_Editor.target != null) + { + if (!canEditAsset && GUILayout.Button("Check out")) + { + Task task = Provider.Checkout(AssetDatabase.GetAssetPath(m_Editor.target), CheckoutMode.Asset); + task.Wait(); + } + } + } + } + + void AssetFieldWithCreateButton(Rect position, SerializedProperty property, + string title, string defaultName, string extension, string message) + { + EditorGUI.BeginChangeCheck(); + + float hSpace = 5; + float buttonWidth = GUI.skin.button.CalcSize(m_CreateButtonGUIContent).x; + + var r = position; + r.width -= buttonWidth + hSpace; + EditorGUI.PropertyField(r, property); + r.x += r.width + hSpace; + r.width = buttonWidth; + if (GUI.Button(r, m_CreateButtonGUIContent)) + { + string newAssetPath = EditorUtility.SaveFilePanelInProject( + title, defaultName, extension, message); + if (!string.IsNullOrEmpty(newAssetPath)) + { + var asset = CreateAt(_type, newAssetPath); + property.objectReferenceValue = asset; + property.serializedObject.ApplyModifiedProperties(); + } + } + + if (EditorGUI.EndChangeCheck()) + { + property.serializedObject.ApplyModifiedProperties(); + UpdateEditor(property); + } + } + + void DestroyEditor() + { + if (m_Editor != null) + { + UnityEngine.Object.DestroyImmediate(m_Editor); + m_Editor = null; + } + } + + void UpdateEditor(SerializedProperty property) + { + property.serializedObject.ApplyModifiedProperties(); + + var target = property.objectReferenceValue; + if (m_Editor && m_Editor.target != target) + { + DestroyEditor(); + } + + if (target != null) + { + if (!m_Editor) + { + m_Editor = UnityEditor.Editor.CreateEditor(target); + } + } + } + + public static ScriptableObject CreateAt(Type assetType, string assetPath) + { + ScriptableObject asset = ScriptableObject.CreateInstance(assetType); + if (!asset) + { + Debug.LogError("Failed to create instance of " + assetType.Name + " at " + assetPath); + return null; + } + + AssetDatabase.CreateAsset(asset, assetPath); + return asset; + } + } +} \ No newline at end of file diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetEditor.cs.meta b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetEditor.cs.meta new file mode 100644 index 00000000..8c7afd66 --- /dev/null +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/EmbeddedAssetEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 63f79aabdd614d20a214af69939cd772 +timeCreated: 1666142031 \ No newline at end of file diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorExtensions.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorExtensions.cs index 667793a3..a07a5b3a 100644 --- a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorExtensions.cs +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorExtensions.cs @@ -43,6 +43,10 @@ namespace HurricaneVR.Editor value = EditorGUILayout.ObjectField(label, value, typeof(HVRJointSettings), false) as HVRJointSettings; } + public static void StrengthField(string label, ref PDStrength value) + { + value = EditorGUILayout.ObjectField(label, value, typeof(PDStrength), false) as PDStrength; + } public static void Header(string label) { diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorManager.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorManager.cs index 114cc9a8..512fcd74 100644 --- a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorManager.cs +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVREditorManager.cs @@ -9,7 +9,7 @@ namespace HurricaneVR.Editor public class HVREditorManager { private const string HurricaneVRUploader = "HurricaneVRUploader"; - public const string Version = "2.8.4"; + public const string Version = "2.9.1f"; [InitializeOnLoadMethod] private static void Hook() diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRGunCreator.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRGunCreator.cs index 72d45a5d..db3731e0 100644 --- a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRGunCreator.cs +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRGunCreator.cs @@ -7,13 +7,14 @@ using HurricaneVR.Framework.Core.HandPoser; using HurricaneVR.Framework.Core.ScriptableObjects; using HurricaneVR.Framework.Core.Utils; using HurricaneVR.Framework.Shared; +using HurricaneVR.Framework.Shared.Utilities; using HurricaneVR.Framework.Weapons; using HurricaneVR.Framework.Weapons.Guns; using HurricaneVR.Framework.Weapons.Guns.PartFinders; using UnityEditor; using UnityEngine; +using HVRPistol = HurricaneVR.Framework.Weapons.Guns.HVRPistol; using Object = UnityEngine.Object; -using Zero; namespace HurricaneVR.Editor { @@ -26,8 +27,8 @@ namespace HurricaneVR.Editor //private const string TwoHandPistol = "HandSettings/HVR_Pistol_TwoHand"; //private const string TwoHandLarge = "HandSettings/HVR_LargeWeapon_TwoHanded"; - private const string TwoHandLargeStabilizer = "HandSettings/HVR_Stabilizer_TwoHanded"; - private const string TwoHandPistolStabilizer = "HandSettings/HVR_Pistol_Stabilizer_TwoHanded"; + private const string TwoHandLargeStabilizer = "HandSettings/HVR_Stabilizer_TwoHanded_Strength"; + private const string TwoHandPistolStabilizer = "HandSettings/HVR_Pistol_Stabilizer_TwoHanded_Strength"; //private const string OneHandPistol = "HandSettings/HVR_Pistol_OneHand"; //private const string OneHandDefault = "HandSettings/HVR_DefaultHandSettings"; @@ -48,7 +49,7 @@ namespace HurricaneVR.Editor private float _gunMass = 1.5f; private float _bulletSpeed = 80f; private int _rpm = 900; - private FireType _firingType; + private GunFireType _firingType; private HVRHandPose _gripPose; private HVRHandPose _stabilizerPose; @@ -67,9 +68,9 @@ namespace HurricaneVR.Editor private bool _stabilizerRequiresGripGrabbed = true; private bool _stabilizerDropsOnGripReleased = true; private float _cycleTime = .05f; - private HVRJointSettings _gripOneHand; - private HVRJointSettings _gripTwoHand; - private HVRJointSettings _stabilizerTwoHand; + private PDStrength _gripOneHand; + private PDStrength _gripTwoHand; + private PDStrength _stabilizerTwoHand; private bool _ejectedBulletPooled = true; private HVRRecoilSettings _recoilSettings; private Vector2 _scrollPosition; @@ -127,7 +128,7 @@ namespace HurricaneVR.Editor HVREditorExtensions.IntField("Rounds Per Minute", ref _rpm); HVREditorExtensions.FloatField("Bullet Speed", ref _bulletSpeed); - _firingType = (FireType)EditorGUILayout.EnumPopup("Firing Mode", _firingType); + _firingType = (GunFireType)EditorGUILayout.EnumPopup("Firing Mode", _firingType); var currentType = _gunType; _gunType = (HVRGunType)EditorGUILayout.EnumPopup("Type", _gunType); _hitLayerMask = LayerMaskDrawer.LayerMaskField("Hit Layer Mask", _hitLayerMask); @@ -179,9 +180,9 @@ namespace HurricaneVR.Editor // PopulateDefaultHandSettings(); //} - HVREditorExtensions.JointField("Grip One Handed", ref _gripOneHand); - HVREditorExtensions.JointField("Grip Two Handed", ref _gripTwoHand); - HVREditorExtensions.JointField("Stabilizer Two Handed", ref _stabilizerTwoHand); + HVREditorExtensions.StrengthField("Grip One Handed", ref _gripOneHand); + HVREditorExtensions.StrengthField("Grip Two Handed", ref _gripTwoHand); + HVREditorExtensions.StrengthField("Stabilizer Two Handed", ref _stabilizerTwoHand); GUILayout.Space(20f); HVREditorExtensions.Header("SFX"); @@ -377,8 +378,8 @@ namespace HurricaneVR.Editor Undo.RegisterCreatedObjectUndo(root, _gunPrefab.name); gunGrabbable = AddGrabbable(root, out var poser, out var gp); - gunGrabbable.OneHandJointSettings = _gripOneHand; - gunGrabbable.TwoHandJointSettings = _gripTwoHand; + gunGrabbable.OneHandStrength = _gripOneHand; + gunGrabbable.TwoHandStrength = _gripTwoHand; poser.PrimaryPose.Pose = _gripPose; gunGrabbable.HoldType = HVRHoldType.Swap; gunGrabbable.RequireOverlapClearance = true; @@ -398,19 +399,19 @@ namespace HurricaneVR.Editor private GameObject CreatePistol() { - var root = CreateGun(out var gunGrabbable, out var model, out var gun); + var root = CreateGun(out var gunGrabbable, out var model, out var gun); return root; } private GameObject CreateAutomatic() { - var root = CreateGun(out var gunGrabbable, out var model, out var gun); + var root = CreateGun(out var gunGrabbable, out var model, out var gun); return root; } private GameObject CreatePumpShotgun() { - var root = CreateGun(out var gunGrabbable, out var model, out var gun); + var root = CreateGun(out var gunGrabbable, out var model, out var gun); var mag = root.AddComponent(); gun.ChambersAfterFiring = false; mag.MaxCount = 5; @@ -454,9 +455,8 @@ namespace HurricaneVR.Editor //grabbable.TrackingType = HVRGrabTracking.None; grabbable.HoldType = HVRHoldType.OneHand; grabbable.DisableHandCollision = true; - grabbable.PoseImmediately = true; grabbable.ForceGrabbable = false; - grabbable.TwoHandJointSettings = _stabilizerTwoHand; + grabbable.TwoHandStrength = _stabilizerTwoHand; grabbable.ExtraIgnoreCollisionParents = new List() { gunGrabbable.Rigidbody.transform }; if (_stabilizerRequiresGripGrabbed) @@ -500,6 +500,10 @@ namespace HurricaneVR.Editor gun.RecoilComponent = gun.gameObject.AddComponent(); gun.RecoilComponent.Settings = _recoilSettings; gun.GunSounds = gun.gameObject.AddComponent(); + gun.GunSounds.Fired = FiredSFX; + gun.GunSounds.OutOfAmmo = DryFireSFX; + gun.GunSounds.SlideBack = CockedBackSFX; + gun.GunSounds.SlideForward = CockedForwardSFX; gun.Bolt = bolt; var adjustTransforms = AddAdjustTransform(gun.gameObject); diff --git a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRHandPoserEditor.cs b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRHandPoserEditor.cs index 4614ef32..f26efc58 100644 --- a/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRHandPoserEditor.cs +++ b/ZeroPacientVR/Assets/HurricaneVR/Framework/Editor/HVRHandPoserEditor.cs @@ -14,6 +14,12 @@ using UnityEngine; using UnityEngine.UIElements; using Object = UnityEngine.Object; +#if UNITY_2021_2_OR_NEWER +using UnityEditor.SceneManagement; +#else +using UnityEditor.Experimental.SceneManagement; +#endif + namespace HurricaneVR.Editor { [CustomEditor(typeof(HVRHandPoser))] @@ -108,10 +114,7 @@ namespace HurricaneVR.Editor private HVRHandPoseBlend PrimaryPose { - get - { - return Poser.PrimaryPose; - } + get { return Poser.PrimaryPose; } set { Poser.PrimaryPose = value; @@ -121,10 +124,7 @@ namespace HurricaneVR.Editor public HVRHandPose SelectedPose { - get - { - return SelectedBlendPose?.Pose; - } + get { return SelectedBlendPose?.Pose; } set { if (SelectedBlendPose == null) return; @@ -184,7 +184,6 @@ namespace HurricaneVR.Editor { SceneView.duringSceneGui -= OnSceneGUI2; SceneView.duringSceneGui += OnSceneGUI2; - } @@ -225,7 +224,6 @@ namespace HurricaneVR.Editor } foreach (var c in cleanup) _map.Remove(c); - } private void GetHands(ref HVRPosableHand leftHand, ref HVRPosableHand rightHand) @@ -414,6 +412,7 @@ namespace HurricaneVR.Editor { selectedFinger = i; } + selectedBone = bone.Transform; } } @@ -425,6 +424,9 @@ namespace HurricaneVR.Editor } } + private bool _inPrefabMode; + private bool _active; + private void OnEnable() { Poser = target as HVRHandPoser; @@ -452,13 +454,30 @@ namespace HurricaneVR.Editor _root = new VisualElement(); _tree = UnityEngine.Resources.Load("HVRHandPoserEditor"); + + var stage = PrefabStageUtility.GetPrefabStage(Poser.gameObject); + _inPrefabMode = stage != null; + + _active = true; + var s = _root.schedule.Execute(EditorUpdate); + s.Every(1000); + s.Until(() => !_active); + } + + private void EditorUpdate() + { + CheckRigidBody(); + } + + private void OnDisable() + { + _active = false; } private void CreatePoseIfNeeded() { if (PrimaryPose.Pose == null && HVRSettings.Instance.OpenHandPose) { - _root.schedule.Execute(() => { PrimaryPose.SetDefaults(); @@ -473,7 +492,6 @@ namespace HurricaneVR.Editor public override VisualElement CreateInspectorGUI() { - _root.Clear(); _tree.CloneTree(_root); @@ -495,99 +513,111 @@ namespace HurricaneVR.Editor SetupHandButtons(); SetupAutoPoseButtons(); + //can't remember why I would add this field on the ui... + //_selectionIndexField = new IntegerField("SelectedIndex"); + //_selectionIndexField.bindingPath = "SelectionIndex"; + //_selectionIndexField.RegisterValueChangedCallback(evt => + //{ + // if (PosesListView.selectedIndex != evt.newValue) PosesListView.selectedIndex = evt.newValue; + //}); + //_root.Add(_selectionIndexField); - _selectionIndexField = new IntegerField("SelectedIndex"); - _selectionIndexField.bindingPath = "SelectionIndex"; - _selectionIndexField.RegisterValueChangedCallback(evt => + if (_inPrefabMode) { - if (PosesListView.selectedIndex != evt.newValue) PosesListView.selectedIndex = evt.newValue; - }); - _root.Add(_selectionIndexField); - - PreviewLeftToggle = _root.Q("PreviewLeft"); - PreviewLeftToggle.BindProperty(SP_PreviewLeft); - PreviewRightToggle = _root.Q("PreviewRight"); - PreviewRightToggle.BindProperty(SP_PreviewRight); - - PreviewLeftToggle.RegisterValueChangedCallback(OnPreviewLeftChanged); - PreviewRightToggle.RegisterValueChangedCallback(OnPreviewRightChanged); - - ToggleLeftAutoPose = _root.Q("LeftAutoPose"); - ToggleLeftAutoPose.BindProperty(SP_LeftAutoPose); - ToggleRightAutoPose = _root.Q("RightAutoPose"); - ToggleRightAutoPose.BindProperty(SP_RightAutoPose); - - ToggleLeftAutoPose.RegisterValueChangedCallback(OnLeftAutoPoseChanged); - ToggleRightAutoPose.RegisterValueChangedCallback(OnRightAutoPoseChanged); - - if (SelectedIndex >= PosesListView.itemsSource.Count + PrimaryIndex) - { - Debug.Log($"Stored SelectedIndex is higher than pose count."); - SelectedIndex = PosesListView.itemsSource.Count - PrimaryIndex - 1; - serializedObject.ApplyModifiedProperties(); - } - - PosesListView.selectedIndex = SelectedIndex; - - - GetPhysicsPosers(); - - if (FullBody) - { - var body = GameObject.Find(_bodyId); - if (body) - { - SP_BodyPreview.objectReferenceValue = body; - } - - UpdateBodyPreview(SelectedPose != null ? SelectedPose.LeftHand : null, SelectedPose != null ? SelectedPose.RightHand : null, PreviewLeft, PreviewRight); + _root.Q("MirrorAxis").style.display = DisplayStyle.None; + _root.Q("boxPreview").style.display = DisplayStyle.None; } else { - SP_PreviewLeft.boolValue = SP_LeftHandPreview.objectReferenceValue != null; - SP_PreviewRight.boolValue = SP_RightHandPreview.objectReferenceValue != null; + _root.Q("warning").style.display = DisplayStyle.None; - if (!SP_PreviewLeft.boolValue) + PreviewLeftToggle = _root.Q("PreviewLeft"); + PreviewLeftToggle.BindProperty(SP_PreviewLeft); + PreviewRightToggle = _root.Q("PreviewRight"); + PreviewRightToggle.BindProperty(SP_PreviewRight); + + PreviewLeftToggle.RegisterValueChangedCallback(OnPreviewLeftChanged); + PreviewRightToggle.RegisterValueChangedCallback(OnPreviewRightChanged); + + ToggleLeftAutoPose = _root.Q("LeftAutoPose"); + + ToggleLeftAutoPose.BindProperty(SP_LeftAutoPose); + ToggleRightAutoPose = _root.Q("RightAutoPose"); + ToggleRightAutoPose.BindProperty(SP_RightAutoPose); + + ToggleLeftAutoPose.RegisterValueChangedCallback(OnLeftAutoPoseChanged); + ToggleRightAutoPose.RegisterValueChangedCallback(OnRightAutoPoseChanged); + + if (SelectedIndex >= PosesListView.itemsSource.Count + PrimaryIndex) { - FindPreviewHand(true, out var left); - if (left) + Debug.Log($"Stored SelectedIndex is higher than pose count."); + SelectedIndex = PosesListView.itemsSource.Count - PrimaryIndex - 1; + serializedObject.ApplyModifiedProperties(); + } + + PosesListView.selectedIndex = SelectedIndex; + + + GetPhysicsPosers(); + + if (FullBody) + { + var body = GameObject.Find(_bodyId); + if (body) { - SP_PreviewLeft.boolValue = true; - SP_LeftHandPreview.objectReferenceValue = left; + SP_BodyPreview.objectReferenceValue = body; } - } - if (!SP_PreviewRight.boolValue) + UpdateBodyPreview(SelectedPose != null ? SelectedPose.LeftHand : null, SelectedPose != null ? SelectedPose.RightHand : null, PreviewLeft, PreviewRight); + } + else { - FindPreviewHand(false, out var right); - if (right) + SP_PreviewLeft.boolValue = SP_LeftHandPreview.objectReferenceValue != null; + SP_PreviewRight.boolValue = SP_RightHandPreview.objectReferenceValue != null; + + if (!SP_PreviewLeft.boolValue) { - SP_PreviewRight.boolValue = true; - SP_RightHandPreview.objectReferenceValue = right; + FindPreviewHand(true, out var left); + if (left) + { + SP_PreviewLeft.boolValue = true; + SP_LeftHandPreview.objectReferenceValue = left; + } } + + if (!SP_PreviewRight.boolValue) + { + FindPreviewHand(false, out var right); + if (right) + { + SP_PreviewRight.boolValue = true; + SP_RightHandPreview.objectReferenceValue = right; + } + } + + UpdatePreview(false, SP_PreviewRight.boolValue, SelectedPose != null ? SelectedPose.LeftHand : null); + UpdatePreview(true, SP_PreviewLeft.boolValue, SelectedPose != null ? SelectedPose.RightHand : null); } - UpdatePreview(false, SP_PreviewRight.boolValue, SelectedPose != null ? SelectedPose.LeftHand : null); - UpdatePreview(true, SP_PreviewLeft.boolValue, SelectedPose != null ? SelectedPose.RightHand : null); + if (_leftPhysicsPoser) + { + SP_LeftAutoPose.boolValue = _leftPhysicsPoser.LiveUpdate; + } + else + { + SP_LeftAutoPose.boolValue = false; + } + + if (_rightPhysicsPoser) + { + SP_RightAutoPose.boolValue = _rightPhysicsPoser.LiveUpdate; + } + else + { + SP_RightAutoPose.boolValue = false; + } } - if (_leftPhysicsPoser) - { - SP_LeftAutoPose.boolValue = _leftPhysicsPoser.LiveUpdate; - } - else - { - SP_LeftAutoPose.boolValue = false; - } - - if (_rightPhysicsPoser) - { - SP_RightAutoPose.boolValue = _rightPhysicsPoser.LiveUpdate; - } - else - { - SP_RightAutoPose.boolValue = false; - } serializedObject.ApplyModifiedProperties(); @@ -650,6 +680,7 @@ namespace HurricaneVR.Editor { return; } + _rightPhysicsPoser.LiveUpdate = evt.newValue; } } @@ -663,6 +694,7 @@ namespace HurricaneVR.Editor { return; } + _leftPhysicsPoser.LiveUpdate = evt.newValue; } } @@ -709,12 +741,10 @@ namespace HurricaneVR.Editor { _rightPhysicsPoser.LiveUpdate = SP_RightAutoPose.boolValue; } - } private void OnPreviewLeftChanged(ChangeEvent evt) { - CreatePoseIfNeeded(); if (FullBody) @@ -757,6 +787,18 @@ namespace HurricaneVR.Editor } } + private void CheckRigidBody() + { + var g = Poser.GetComponentInParent(); + Rigidbody rb = null; + if (g) + { + rb = g.gameObject.GetComponent(); + } + + _root.Q("lblAutoPoseWarning").style.display = rb ? DisplayStyle.Flex : DisplayStyle.None; + } + private void UpdateBodyPreview(HVRHandPoseData leftpose, HVRHandPoseData rightpose, bool previewLeft, bool previewRight, bool poseChanged = false) { if (!previewRight && !previewLeft) @@ -769,6 +811,7 @@ namespace HurricaneVR.Editor SetupIKTarget(previewLeft, "LeftIKTarget", out var dummy); SetupIKTarget(previewRight, "RightIKTarget", out var dummy2); } + return; } @@ -863,7 +906,6 @@ namespace HurricaneVR.Editor } - SceneView.RepaintAll(); serializedObject.ApplyModifiedProperties(); @@ -958,6 +1000,9 @@ namespace HurricaneVR.Editor private void OnSelectedPoseChanged(ChangeEvent evt) { + if (_inPrefabMode) + return; + if (evt.newValue != null) { var newPose = evt.newValue as HVRHandPose; @@ -1289,7 +1334,6 @@ namespace HurricaneVR.Editor rightHand.Pose(right); } } - }; var mirrorLeft = _root.Q