mirror of
https://github.com/nothke/quality-control.git
synced 2024-11-12 22:03:42 +00:00
Added interaction, hand, rigidbody dragging, picking up hammer
This commit is contained in:
parent
93ecc95bfa
commit
d2c3dff101
109
Assets/Meshes/hammer.fbx.meta
Normal file
109
Assets/Meshes/hammer.fbx.meta
Normal file
@ -0,0 +1,109 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 284d0eff2a70da04dbcbde75060e045d
|
||||
ModelImporter:
|
||||
serializedVersion: 22200
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importPhysicalCameras: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
strictVertexDataChecks: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 0
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 2
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
importBlendShapeDeformPercent: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction.meta
Normal file
8
Assets/Plugins/Interaction.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f85848e00a41f4d45836e2763098c7b2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
Assets/Plugins/Interaction/README.md
Normal file
30
Assets/Plugins/Interaction/README.md
Normal file
@ -0,0 +1,30 @@
|
||||
#### Simple interaction
|
||||
- Add `InteractionController` component to your camera
|
||||
- You must provide an input for the controller, so add `ExampleInteractionControllerInput` to the same object. Implement your own to provide custom input.
|
||||
- Drop `Example Interaction Canvas.prefab` into the scene to get some UI feedback. If you wish to customize it, make a copy of the prefab and customize as you wish.
|
||||
- To create an interactable object, create a new script and inherit `Nothke.Interaction.Interactable`. Override `void Use(InteractableController im)` and add `Debug.Log("Hello, interactable!")`. When you click on it, you should get a message in your log.
|
||||
|
||||
#### Holding Items
|
||||
Item handling is a separate system that builds on top of simple interaction. It is managed by the `Hands` component, residing in `Nothke.Interaction.Items` namespace, which manages taking, throwing, interacting with held items etc.
|
||||
- Add a `Hands` component to where your `InteractionController` is (you can also assign it to the handsComponent property on the InteractionController if you don't want to put it on the same object);
|
||||
- Now if you create a new script that inherits `Interactable` and also implements `ITakeable`, you will be able to take it;
|
||||
- Note that you will have to also implement IDroppable to be able to drop the item
|
||||
|
||||
#### Specifying interactable behavior
|
||||
Specifying interaction on interactables is handled via interfaces. For example `ITakeable` makes the interactable takeable, while `IScrollInteractable` makes it possible to implement value changing when interacting with the mouse scroll wheel. Or you can specify which item can interact with which item by implementing `IItemInHandsInteractionDependable` or `ICanInteract`. See [InteractionInterfaces.cs](Runtime/Core/InteractionInterfaces.cs) for a full list of built-in interaction interfaces.
|
||||
|
||||
#### Default implementations
|
||||
The package also provides a few default implementations of aformentioned interfaces, which can be inherited for a much easier implmentation, such as:
|
||||
- `GenericItem` which implements holdable item in a single class, behavior of which can be configured in the inspector, or by overriding virtual functions;
|
||||
- `Slot` provides a default implementation for slotting, that is, an interactable that can accept another item. I.e. an electricity socket which can accept a plug.
|
||||
|
||||
So, why is "low level" implmementation provided via interfaces and not via classes like these? Well, because there could be conflicting behaviors, like, what if I want to make a takeable item, which is also a slot? You can totally do that with just implmementing all the necessary interfaces.
|
||||
|
||||
#### Interfacing with other game features
|
||||
InteractionController needs to interact with a few features that depend on your implemention in your project, such as mouse look locking. This functionality is done by providing the InteractionController with interfaces, these are located in [IntegrationInterfaces.cs](Runtime/Integration/IntegrationInterfaces.cs).
|
||||
|
||||
#### UI
|
||||
The package provides an implementation of a simple UI, which shows an interactable's label and also shows a reticle that changes on the item behavior. Best is if you use this as an example of how to implement your own UI.
|
||||
|
||||
#### To be changed in the future:
|
||||
- The project currently uses reticle sprites that are managed by `ReticleUI.cs` and switch according to an enum. It should either be changed to a class that can be extended, or removed completely and user should be encouraged to create their own.
|
7
Assets/Plugins/Interaction/README.md.meta
Normal file
7
Assets/Plugins/Interaction/README.md.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bc51f0323be70a4e9a6fe407e458eee
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime.meta
Normal file
8
Assets/Plugins/Interaction/Runtime.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2003b7f937eaeb45b7fab9ea84c1545
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/Core.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/Core.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c06ebe8037b3d449ad53636b0a4b49a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Assets/Plugins/Interaction/Runtime/Core/Interactable.cs
Normal file
37
Assets/Plugins/Interaction/Runtime/Core/Interactable.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public class Interactable : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public InteractionController manager;
|
||||
|
||||
[System.Serializable]
|
||||
public class Info
|
||||
{
|
||||
public string name;
|
||||
|
||||
//public string descriptionShort;
|
||||
//[Multiline()]
|
||||
//public string description;
|
||||
}
|
||||
|
||||
public Info info;
|
||||
public virtual string Label => info.name;
|
||||
|
||||
public virtual void Use(InteractionController im)
|
||||
{
|
||||
manager = im;
|
||||
//Debug.Log("No use");
|
||||
}
|
||||
|
||||
public virtual void OnHover() { }
|
||||
public virtual void OnDehover() { }
|
||||
|
||||
public virtual void StartHold() { }
|
||||
public virtual void EndHold() { }
|
||||
public virtual void UseHold() { }
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Core/Interactable.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Core/Interactable.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db4c87c72dc0dbd418a87afc01249dad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Assets/Plugins/Interaction/Runtime/Core/InteractableUtils.cs
Normal file
36
Assets/Plugins/Interaction/Runtime/Core/InteractableUtils.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public static class InteractableUtils
|
||||
{
|
||||
|
||||
public static Vector3 GetMousePointOnPlane(Plane plane)
|
||||
{
|
||||
Vector3 screenPoint = Input.mousePosition;
|
||||
|
||||
Ray screenRay = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
|
||||
float e = 0;
|
||||
if (plane.Raycast(screenRay, out e))
|
||||
screenPoint.z = e;
|
||||
|
||||
return screenRay.GetPoint(e);
|
||||
}
|
||||
|
||||
public static Vector3 GetJointAnchorInWorldSpace(Joint joint)
|
||||
{
|
||||
if (!joint.connectedBody) return joint.connectedAnchor;
|
||||
|
||||
return joint.connectedBody.transform.TransformPoint(joint.connectedAnchor);
|
||||
}
|
||||
|
||||
public static bool IsNonUniform(this Transform transform)
|
||||
{
|
||||
Vector3 ls = transform.lossyScale;
|
||||
return !(Mathf.Approximately(ls.x, ls.y) && Mathf.Approximately(ls.y, ls.z));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d67801240ba9824885c0e8255eda458
|
||||
timeCreated: 1530288663
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
342
Assets/Plugins/Interaction/Runtime/Core/InteractionController.cs
Normal file
342
Assets/Plugins/Interaction/Runtime/Core/InteractionController.cs
Normal file
@ -0,0 +1,342 @@
|
||||
//#define NEVER_MOUSE_RAY
|
||||
#define USE_FIXED_UPDATE
|
||||
|
||||
using UnityEngine;
|
||||
using Nothke.Interaction.Items;
|
||||
using Nothke.Interaction.Integration;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public class InteractionController : MonoBehaviour
|
||||
{
|
||||
Transform originTransform;
|
||||
|
||||
public float interactDistance = 2;
|
||||
|
||||
public bool rayModeToggling = false;
|
||||
public bool mouseRay = false;
|
||||
|
||||
public MonoBehaviour lockableFreeLookComponent;
|
||||
ILockableFreeLook lockableFreeLook;
|
||||
|
||||
Interactable interactable;
|
||||
Interactable lastHovered;
|
||||
|
||||
public Interactable hovered { get; private set; }
|
||||
|
||||
public MonoBehaviour handsComponent;
|
||||
public IHands hands;
|
||||
public LayerMask raycastLayerMask = -1;
|
||||
|
||||
[HideInInspector]
|
||||
public Vector3 startScreenPosition;
|
||||
|
||||
[System.NonSerialized]
|
||||
public RaycastHit hit;
|
||||
[System.NonSerialized]
|
||||
public bool hasHit;
|
||||
|
||||
bool LMB;
|
||||
bool LMBup;
|
||||
bool rayModeToggleDown;
|
||||
|
||||
bool freezeDetection;
|
||||
public bool detectionFrozen => freezeDetection;
|
||||
|
||||
bool isDetached;
|
||||
bool wasMouseRayBeforeTemp;
|
||||
|
||||
public delegate void HoverAction(Interactable interactable);
|
||||
public event HoverAction OnHover;
|
||||
public delegate void DehoverAction();
|
||||
public event DehoverAction OnDehover;
|
||||
public delegate void RayModeChangeAction(bool enable);
|
||||
public event RayModeChangeAction OnRayModeChange;
|
||||
|
||||
public bool debug;
|
||||
|
||||
Camera cam;
|
||||
|
||||
protected Ray interactionRay;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (handsComponent)
|
||||
{
|
||||
hands = handsComponent.GetComponent<IHands>();
|
||||
hands.controller = this;
|
||||
Debug.Assert(hands != null, "Assigned component doesn't implement IHands");
|
||||
}
|
||||
else
|
||||
{
|
||||
hands = GetComponent<IHands>();
|
||||
if (hands != null)
|
||||
hands.controller = this;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
cam = Camera.main;
|
||||
|
||||
if (lockableFreeLookComponent)
|
||||
{
|
||||
lockableFreeLook = lockableFreeLookComponent.GetComponent<ILockableFreeLook>();
|
||||
|
||||
if (lockableFreeLook == null)
|
||||
Debug.Log("ILockableFreeLook not found on assigned component", lockableFreeLookComponent);
|
||||
}
|
||||
|
||||
originTransform = transform;
|
||||
|
||||
Dehover();
|
||||
|
||||
SetRayMode(mouseRay);
|
||||
}
|
||||
|
||||
public void SetTempRayOrigin(Transform t)
|
||||
{
|
||||
originTransform = t;
|
||||
}
|
||||
|
||||
public void ResetTempRayOrigin()
|
||||
{
|
||||
originTransform = transform;
|
||||
}
|
||||
|
||||
public void SetInput(bool interactDown, bool interactUp, bool rayModeChangeDown)
|
||||
{
|
||||
LMB = interactDown;
|
||||
LMBup = interactUp;
|
||||
this.rayModeToggleDown = rayModeChangeDown;
|
||||
}
|
||||
|
||||
public void UpdateRaycast()
|
||||
{
|
||||
if (mouseRay)
|
||||
interactionRay = cam.ScreenPointToRay(Input.mousePosition);
|
||||
else
|
||||
interactionRay = new Ray(originTransform.position, originTransform.forward);
|
||||
|
||||
hovered = null;
|
||||
|
||||
// DETECTION - Raycast
|
||||
if (!freezeDetection)
|
||||
{
|
||||
GameObject hito = GetInteractingObject();
|
||||
|
||||
if (hito)
|
||||
{
|
||||
hasHit = true;
|
||||
|
||||
hovered = hito.GetComponentInParent<Interactable>();
|
||||
|
||||
// Prevent interaction with items that don't want to be interacted with
|
||||
// unless holding a certain item
|
||||
if (hovered is IItemInHandsInteractionDependable)
|
||||
{
|
||||
if (hands == null)
|
||||
hovered = null;
|
||||
else
|
||||
if (!(hovered as IItemInHandsInteractionDependable).IsInteractableIfHolding(hands.item))
|
||||
hovered = null;
|
||||
}
|
||||
|
||||
// Prevent interaction if item in hands prevents interaction
|
||||
if (hands != null && hands.item && hands.item is IEnvironmentInteractionPreventable eip)
|
||||
{
|
||||
if (!eip.EnvironmentInteractionIsAllowed)
|
||||
hovered = null;
|
||||
}
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (hovered is ISelectiveInteractable)
|
||||
{
|
||||
if (!(hovered as ISelectiveInteractable).CanInteract)
|
||||
hovered = null;
|
||||
}
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
if (hovered is ICanInteract)
|
||||
{
|
||||
if (!(hovered as ICanInteract).CanInteract(this))
|
||||
hovered = null;
|
||||
}
|
||||
|
||||
if (hovered != lastHovered && hovered != null)
|
||||
Hover(hovered);
|
||||
}
|
||||
else hasHit = false;
|
||||
|
||||
if (hovered != lastHovered && hovered == null)
|
||||
Dehover();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this to provide a custom raycaster for example. You can get the default provided ray from interactionRay.
|
||||
/// </summary>
|
||||
protected virtual GameObject GetInteractingObject()
|
||||
{
|
||||
if (Physics.Raycast(interactionRay, out hit, interactDistance, raycastLayerMask))
|
||||
return hit.collider.gameObject;
|
||||
else return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this after you set input. Should be called in Update()
|
||||
/// </summary>
|
||||
public void UpdateInput()
|
||||
{
|
||||
// On click
|
||||
bool interactedThisFrame = false;
|
||||
if (hovered && LMB)
|
||||
{
|
||||
interactable = hovered;
|
||||
|
||||
if (hands != null && interactable is ITakeable)
|
||||
{
|
||||
if (interactable is ISelectiveTakeable)
|
||||
{
|
||||
if ((interactable as ISelectiveTakeable).CanBeTaken())
|
||||
hands.Take(interactable as ITakeable);
|
||||
}
|
||||
else
|
||||
hands.Take(interactable as ITakeable);
|
||||
}
|
||||
|
||||
interactable.Use(this);
|
||||
interactable.StartHold();
|
||||
interactedThisFrame = true;
|
||||
|
||||
startScreenPosition = Input.mousePosition;
|
||||
}
|
||||
|
||||
// On scroll
|
||||
if (hovered && hovered is IScrollInteractable scrollInteractable)
|
||||
{
|
||||
float scroll = Input.mouseScrollDelta.y;
|
||||
|
||||
if (scroll != 0)
|
||||
scrollInteractable.Scroll(this, scroll);
|
||||
}
|
||||
|
||||
// On release
|
||||
if (interactable && LMBup)
|
||||
{
|
||||
interactable.EndHold();
|
||||
interactable = null;
|
||||
}
|
||||
|
||||
lastHovered = hovered;
|
||||
|
||||
LMB = false;
|
||||
LMBup = false;
|
||||
|
||||
if (!interactedThisFrame && hands != null)
|
||||
hands.UpdateInteraction();
|
||||
}
|
||||
|
||||
public void Recast()
|
||||
{
|
||||
hovered = null;
|
||||
}
|
||||
|
||||
void ToggleRayMode()
|
||||
{
|
||||
mouseRay = !mouseRay;
|
||||
|
||||
SetRayMode(mouseRay);
|
||||
}
|
||||
|
||||
public void FreezeDetection()
|
||||
{
|
||||
freezeDetection = true;
|
||||
hovered = null;
|
||||
}
|
||||
|
||||
public void UnfreezeDetection()
|
||||
{
|
||||
freezeDetection = false;
|
||||
Dehover();
|
||||
Recast();
|
||||
}
|
||||
|
||||
public void SetTempMouseRay(bool tempMouse)
|
||||
{
|
||||
if (tempMouse)
|
||||
{
|
||||
wasMouseRayBeforeTemp = mouseRay;
|
||||
SetRayMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!wasMouseRayBeforeTemp)
|
||||
{
|
||||
SetRayMode(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRayMode(bool isMouse)
|
||||
{
|
||||
mouseRay = isMouse;
|
||||
|
||||
#if !NEVER_MOUSE_RAY
|
||||
if (mouseRay)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
|
||||
// TODO: if windows
|
||||
//System.Windows.Forms.Cursor.Position = new System.Drawing.Point(10, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
//System.Windows.Forms.Cursor.Position = new System.Drawing.Point(Screen.width / 2, Screen.height / 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lockableFreeLook != null)
|
||||
lockableFreeLook.LockFreeLook(mouseRay);
|
||||
else
|
||||
Debug.LogWarning("No freelook lockable");
|
||||
|
||||
OnRayModeChange?.Invoke(mouseRay);
|
||||
|
||||
if (debug)
|
||||
Debug.Log("Ray mode changed to " + (mouseRay ? " Mouse" : " Center"));
|
||||
|
||||
//Cursor.visible = mouseRay;
|
||||
|
||||
if (hands != null)
|
||||
hands.isFixed = mouseRay;
|
||||
}
|
||||
|
||||
void Hover(Interactable interactable)
|
||||
{
|
||||
interactable.OnHover();
|
||||
OnHover?.Invoke(interactable);
|
||||
|
||||
if (debug)
|
||||
Debug.Log("Hovered " + interactable.name);
|
||||
}
|
||||
|
||||
void Dehover()
|
||||
{
|
||||
if (lastHovered)
|
||||
lastHovered.OnDehover();
|
||||
|
||||
OnDehover?.Invoke();
|
||||
|
||||
if (debug)
|
||||
Debug.Log("Dehovered");
|
||||
}
|
||||
|
||||
public void LockFreeLook(bool b)
|
||||
{
|
||||
if (lockableFreeLook != null)
|
||||
lockableFreeLook.LockFreeLook(b);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb45815bc5df925448fc604ec327964b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
145
Assets/Plugins/Interaction/Runtime/Core/InteractionInterfaces.cs
Normal file
145
Assets/Plugins/Interaction/Runtime/Core/InteractionInterfaces.cs
Normal file
@ -0,0 +1,145 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public interface IScrollInteractable
|
||||
{
|
||||
void Scroll(InteractionController im, float scroll);
|
||||
}
|
||||
|
||||
[System.Obsolete("Use ICanInteract instead")]
|
||||
public interface ISelectiveInteractable
|
||||
{
|
||||
bool CanInteract { get; }
|
||||
}
|
||||
|
||||
public interface ICanInteract
|
||||
{
|
||||
bool CanInteract(InteractionController controller);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Nothke.Interaction.Items
|
||||
{
|
||||
public interface IUsable
|
||||
{
|
||||
void Use();
|
||||
}
|
||||
|
||||
public interface IHoldUsable
|
||||
{
|
||||
void UseEnd();
|
||||
}
|
||||
|
||||
public interface IScrollableInHand
|
||||
{
|
||||
void ScrollInHand(float scroll);
|
||||
}
|
||||
|
||||
public interface ISecondaryUsable
|
||||
{
|
||||
bool AllowExamination { get; }
|
||||
void UseSecondary();
|
||||
}
|
||||
|
||||
public interface ITakeable
|
||||
{
|
||||
Transform Transform { get; }
|
||||
Rigidbody Rigidbody { get; }
|
||||
void OnTaken(IHands hands);
|
||||
}
|
||||
|
||||
public interface ICustomHoldPivot
|
||||
{
|
||||
void GetHoldPivot(out Vector3 holdPos, out Quaternion holdRot);
|
||||
}
|
||||
|
||||
public interface IHands
|
||||
{
|
||||
Interactable item { get; }
|
||||
void Take(ITakeable _item);
|
||||
void Drop();
|
||||
void DropFixed();
|
||||
void UpdateInteraction();
|
||||
bool isFixed { get; set; }
|
||||
void Place(Vector3 position, Quaternion rotation, Transform relativeParent, IItemReceivable intoSlot = null);
|
||||
InteractionController controller { get; set; }
|
||||
}
|
||||
|
||||
public interface ISelectiveTakeable
|
||||
{
|
||||
bool CanBeTaken();
|
||||
}
|
||||
|
||||
public interface IDroppable
|
||||
{
|
||||
Transform Transform { get; }
|
||||
Rigidbody Rigidbody { get; }
|
||||
void OnDropped(IHands hands);
|
||||
bool DelayDrop { get; }
|
||||
}
|
||||
|
||||
public interface IThrowable
|
||||
{
|
||||
Rigidbody Rigidbody { get; }
|
||||
bool canThrow { get; }
|
||||
float minThrowAcceleration { get; }
|
||||
float maxThrowAcceleration { get; }
|
||||
void OnDropped(IHands hands);
|
||||
}
|
||||
|
||||
public interface INicePlaceable
|
||||
{
|
||||
void GetPlacePivot(out Vector3 placePos, out Quaternion placeRot);
|
||||
void OnStartedPlacing(IHands hands);
|
||||
void OnNicePlaced(IHands hands);
|
||||
}
|
||||
|
||||
public interface IExaminable
|
||||
{
|
||||
float HorizontalAngle { get; }
|
||||
float VerticalAngle { get; }
|
||||
}
|
||||
|
||||
public interface ICustomExaminePosition
|
||||
{
|
||||
Vector3 ExaminePosition { get; }
|
||||
}
|
||||
|
||||
public interface ICustomHandPosition
|
||||
{
|
||||
Vector3 HandsOffset { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets position of held hand
|
||||
/// </summary>
|
||||
public interface IOverrideHandPositon
|
||||
{
|
||||
Vector3 HandPosition { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds offset translation to held hand
|
||||
/// </summary>
|
||||
public interface IOffsetHandPosition
|
||||
{
|
||||
Vector3 HandPositionOffset { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this if you want to prevent held items interacting with other (environment) interactables
|
||||
/// </summary>
|
||||
public interface IEnvironmentInteractionPreventable
|
||||
{
|
||||
bool EnvironmentInteractionIsAllowed { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this on interactables that you want to be interactable only if the player is holding a certain item
|
||||
/// </summary>
|
||||
public interface IItemInHandsInteractionDependable
|
||||
{
|
||||
bool IsInteractableIfHolding(Interactable item);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6a61181c3b9a7d40a2516b501df78c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/Example.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/Example.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26894b982e08af94c8e058bf230dc98b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction.Example
|
||||
{
|
||||
public class ExampleInteractionControllerInput : MonoBehaviour
|
||||
{
|
||||
public InteractionController controller;
|
||||
public Items.Hands hands;
|
||||
|
||||
public int interactMouseButton = 0;
|
||||
public int rayModeChangeMouseButton = 1;
|
||||
|
||||
public KeyCode dropKey = KeyCode.Q;
|
||||
public KeyCode throwKey = KeyCode.F;
|
||||
public KeyCode examineKey = KeyCode.E;
|
||||
public KeyCode placeKey = KeyCode.T;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
controller.SetInput(
|
||||
Input.GetMouseButtonDown(interactMouseButton),
|
||||
Input.GetMouseButtonUp(interactMouseButton),
|
||||
Input.GetMouseButtonDown(rayModeChangeMouseButton));
|
||||
|
||||
if (hands)
|
||||
{
|
||||
hands.SetInput(new Items.Hands.HandsInput()
|
||||
{
|
||||
useDown = Input.GetMouseButtonDown(0),
|
||||
useUp = Input.GetMouseButtonUp(0),
|
||||
dropDown = Input.GetKeyDown(dropKey),
|
||||
throwDown = Input.GetKeyDown(throwKey),
|
||||
throwUp = Input.GetKeyUp(throwKey),
|
||||
examineDown = Input.GetKeyDown(examineKey),
|
||||
examineUp = Input.GetKeyUp(examineKey),
|
||||
placeDown = Input.GetKeyDown(placeKey)
|
||||
});
|
||||
}
|
||||
|
||||
controller.UpdateInput();
|
||||
controller.UpdateRaycast();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8ad317191c930345bb55655eac9a932
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/Integration.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/Integration.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 220b2e02ec25d3941942cbed7225e0df
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Nothke.Interaction.Items;
|
||||
|
||||
namespace Nothke.Interaction.Integration
|
||||
{
|
||||
public interface ILockableFreeLook
|
||||
{
|
||||
void LockFreeLook(bool _lock);
|
||||
}
|
||||
|
||||
public interface IFocusableEffect
|
||||
{
|
||||
void FocusEffect(bool focus, float distance);
|
||||
}
|
||||
|
||||
public interface IZoomable
|
||||
{
|
||||
void ZoomIn(bool _zoomIn);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 869628a60cfb3be4b84024737f32c758
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/Items.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/Items.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ac69220ba77db048914abfa881f6fce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
141
Assets/Plugins/Interaction/Runtime/Items/GenericItem.cs
Normal file
141
Assets/Plugins/Interaction/Runtime/Items/GenericItem.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction.Items
|
||||
{
|
||||
public class GenericItem : Interactable,
|
||||
ITakeable, IDroppable, IThrowable, INicePlaceable,
|
||||
IExaminable, ICustomHoldPivot
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ItemSettings
|
||||
{
|
||||
//public Vector3 customHoldPosition = new Vector3(0.15f, -0.15f, 0.1f);
|
||||
public Transform holdPivot;
|
||||
|
||||
public Collider[] collidersToDisable;
|
||||
public bool autoPopulateColliderListFromChildren;
|
||||
|
||||
public bool useCustomExaminePosition;
|
||||
public Vector3 customExaminePosition = new Vector3(0, 0, 0.15f);
|
||||
public float examineHorizontalAngle = 90;
|
||||
public float examineVerticalAngle = 90;
|
||||
|
||||
public bool canBeThrown = true;
|
||||
public float minThrowVelocity = 5;
|
||||
public float maxThrowVelocity = 10;
|
||||
|
||||
public Transform nicePlacePivot;
|
||||
}
|
||||
|
||||
public ItemSettings itemSettings;
|
||||
|
||||
public Transform Transform => transform;
|
||||
public Rigidbody Rigidbody => rb;
|
||||
|
||||
public bool DelayDrop => false;
|
||||
|
||||
public float HorizontalAngle => itemSettings.examineHorizontalAngle;
|
||||
public float VerticalAngle => itemSettings.examineVerticalAngle;
|
||||
|
||||
protected Rigidbody rb;
|
||||
Collider col;
|
||||
|
||||
public bool canThrow => itemSettings.canBeThrown;
|
||||
public float minThrowAcceleration => itemSettings.minThrowVelocity;
|
||||
public float maxThrowAcceleration => itemSettings.maxThrowVelocity;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
rb = GetComponentInParent<Rigidbody>();
|
||||
col = GetComponent<Collider>();
|
||||
|
||||
Debug.Assert(rb, "GenericItem has no Rigidbody", this);
|
||||
|
||||
if ((!itemSettings.holdPivot && transform.IsNonUniform()) ||
|
||||
(itemSettings.holdPivot && itemSettings.holdPivot.IsNonUniform()))
|
||||
Debug.LogError("GenericItem's scale (or its hold pivot's scale) is non-uniform, this is not allowed. Placement will be skewed.", this);
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
if (itemSettings == null)
|
||||
itemSettings = new ItemSettings();
|
||||
|
||||
if (itemSettings.autoPopulateColliderListFromChildren)
|
||||
{
|
||||
itemSettings.collidersToDisable = GetComponentsInChildren<Collider>(true);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnDropped(IHands hands)
|
||||
{
|
||||
SetCollisions(true);
|
||||
FixRigidbody(false);
|
||||
}
|
||||
|
||||
public virtual void OnTaken(IHands hands)
|
||||
{
|
||||
SetCollisions(false);
|
||||
FixRigidbody(true);
|
||||
}
|
||||
|
||||
public virtual void OnStartedPlacing(IHands hands)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnNicePlaced(IHands hands)
|
||||
{
|
||||
SetCollisions(true);
|
||||
rb.isKinematic = false;
|
||||
}
|
||||
|
||||
protected void SetCollisions(bool enable)
|
||||
{
|
||||
if (col)
|
||||
col.enabled = enable;
|
||||
|
||||
foreach (Collider col in itemSettings.collidersToDisable)
|
||||
col.enabled = enable;
|
||||
}
|
||||
|
||||
public void FixRigidbody(bool fix)
|
||||
{
|
||||
rb.interpolation = fix ? RigidbodyInterpolation.None : RigidbodyInterpolation.Interpolate;
|
||||
rb.isKinematic = fix;
|
||||
}
|
||||
|
||||
public void GetHoldPivot(out Vector3 holdPos, out Quaternion holdRot)
|
||||
{
|
||||
if (!itemSettings.holdPivot)
|
||||
{
|
||||
holdPos = Vector3.zero;
|
||||
holdRot = Quaternion.identity;
|
||||
}
|
||||
else
|
||||
{
|
||||
holdPos = itemSettings.holdPivot.localPosition;
|
||||
holdRot = itemSettings.holdPivot.localRotation;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetPlacePivot(out Vector3 placePos, out Quaternion placeRot)
|
||||
{
|
||||
if (!itemSettings.nicePlacePivot)
|
||||
{
|
||||
Bounds bounds = Utils.BoundsUtils.GetObjectSpaceColliderBounds(gameObject, true);
|
||||
placePos = bounds.center;
|
||||
placePos.y = bounds.min.y;
|
||||
placeRot = Quaternion.identity;
|
||||
//Debug.Log("Got bounds offset: " + placePos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
placePos = itemSettings.nicePlacePivot.localPosition;
|
||||
placeRot = itemSettings.nicePlacePivot.localRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Items/GenericItem.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Items/GenericItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84817382e549d8b4797caa3a4891df6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
579
Assets/Plugins/Interaction/Runtime/Items/Hands.cs
Normal file
579
Assets/Plugins/Interaction/Runtime/Items/Hands.cs
Normal file
@ -0,0 +1,579 @@
|
||||
using System.Collections.Generic;
|
||||
using Nothke.Interaction.Integration;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Nothke.Interaction.Items
|
||||
{
|
||||
public class Hands : MonoBehaviour, IHands
|
||||
{
|
||||
#region Inspector variables
|
||||
|
||||
public Transform hand;
|
||||
|
||||
public Vector3 handAimPos = new Vector3(0, 0, 0.8f);
|
||||
|
||||
public float examinationMouseSensitivity = 1;
|
||||
|
||||
[Header("Smooth taking")]
|
||||
public bool smoothTake;
|
||||
public float smoothMoveFactor = 0.1f;
|
||||
public float smoothRotateRate = 10;
|
||||
|
||||
[Header("Throwing")]
|
||||
public bool throwFromCenter = true;
|
||||
public float throwUpFactor = 0.2f;
|
||||
public float throwAngularVelocity = 10;
|
||||
public Transform throwTransform;
|
||||
|
||||
public float handNoiseGain = 1;
|
||||
|
||||
[System.NonSerialized] public MonoBehaviour[] mouseLooks; // TODO: Remove
|
||||
public MonoBehaviour lockableFreeLookComponent;
|
||||
ILockableFreeLook lockableFreeLook;
|
||||
public MonoBehaviour focusEffectComponent;
|
||||
IFocusableEffect focusableEffect;
|
||||
|
||||
public bool nicePlacement;
|
||||
|
||||
public bool disableShadowsOnTakenObjects = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
public bool isFixed { get; set; }
|
||||
[System.NonSerialized] public Interactable item;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
const float smoothPlaceTimeLimit = 1;
|
||||
|
||||
Transform itemInHands;
|
||||
|
||||
Vector3 handStartPos;
|
||||
Vector3 handTargetPos;
|
||||
Quaternion handStartRot;
|
||||
Quaternion handTargetRot;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
Vector3 mouseSpeed;
|
||||
Vector3 handRefVelo;
|
||||
|
||||
#if FOV
|
||||
float originalFoV;
|
||||
float FoVRefVelo;
|
||||
#endif
|
||||
|
||||
Interactable IHands.item => item;
|
||||
public InteractionController controller { get; set; }
|
||||
|
||||
Vector3 placeTLocalPos;
|
||||
Quaternion placeTLocalRot;
|
||||
Vector3 placeHandOffset;
|
||||
Quaternion placeHandRotation;
|
||||
Transform placeT;
|
||||
bool placing;
|
||||
bool placingIsNice;
|
||||
float placeStartTime;
|
||||
|
||||
Transform handParent;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public void Take(ITakeable _item)
|
||||
{
|
||||
if (itemInHands) return;
|
||||
|
||||
item = _item as Interactable;
|
||||
|
||||
if (_item.Rigidbody)
|
||||
_item.Rigidbody.isKinematic = true;
|
||||
|
||||
var itemT = _item.Transform;
|
||||
|
||||
Vector3 targetHoldPos = Vector3.zero;
|
||||
Quaternion targetHoldRot = Quaternion.identity;
|
||||
|
||||
if (item is ICustomHoldPivot)
|
||||
(item as ICustomHoldPivot).GetHoldPivot(out targetHoldPos, out targetHoldRot);
|
||||
|
||||
if (smoothTake)
|
||||
{
|
||||
hand.transform.SetPositionAndRotation(
|
||||
itemT.TransformPoint(targetHoldPos),
|
||||
itemT.rotation * targetHoldRot);
|
||||
}
|
||||
|
||||
itemT.parent = hand;
|
||||
|
||||
if (!smoothTake)
|
||||
{
|
||||
itemT.localPosition = -targetHoldPos;
|
||||
itemT.localRotation = Quaternion.Inverse(targetHoldRot);
|
||||
}
|
||||
|
||||
if (disableShadowsOnTakenObjects)
|
||||
EnableShadowcasting(item, true);
|
||||
|
||||
itemInHands = _item.Transform;
|
||||
|
||||
_item.OnTaken(this);
|
||||
}
|
||||
|
||||
public void Drop()
|
||||
{
|
||||
if (!itemInHands) return;
|
||||
|
||||
var droppable = item as IDroppable;
|
||||
|
||||
if (droppable == null) Debug.LogError("Attempting to drop undroppable item");
|
||||
|
||||
Debug.Assert(droppable != null, "Droppable is null");
|
||||
//Debug.Assert(droppable.Rigidbody != null, "Item rigidbody is null");
|
||||
|
||||
if (droppable.Rigidbody)
|
||||
droppable.Rigidbody.isKinematic = false;
|
||||
|
||||
itemInHands.parent = null;
|
||||
|
||||
if (disableShadowsOnTakenObjects)
|
||||
EnableShadowcasting(item, true);
|
||||
|
||||
Debug.Log($"Dropped {item.name}");
|
||||
|
||||
itemInHands = null;
|
||||
item = null;
|
||||
}
|
||||
|
||||
public void DropFixed()
|
||||
{
|
||||
if (!itemInHands) return;
|
||||
|
||||
itemInHands.parent = null;
|
||||
|
||||
if (disableShadowsOnTakenObjects)
|
||||
EnableShadowcasting(item, true);
|
||||
|
||||
Debug.Log($"Dropped fixed {item.name}");
|
||||
|
||||
if (item is IDroppable droppable)
|
||||
droppable.OnDropped(this);
|
||||
|
||||
itemInHands = null;
|
||||
item = null;
|
||||
}
|
||||
|
||||
void EnableShadowcasting(Interactable item, bool enable)
|
||||
{
|
||||
Renderer[] renderers = item.transform.GetComponentsInChildren<Renderer>(); // alloc!
|
||||
for (int i = 0; i < renderers.Length; i++)
|
||||
renderers[i].shadowCastingMode =
|
||||
enable ?
|
||||
UnityEngine.Rendering.ShadowCastingMode.On :
|
||||
UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
}
|
||||
|
||||
IItemReceivable placingIntoSlot;
|
||||
|
||||
public void Place(Vector3 position, Quaternion rotation, Transform relativeParent, IItemReceivable intoSlot = null)
|
||||
{
|
||||
placeT = relativeParent;
|
||||
placeTLocalPos = position;
|
||||
placeTLocalRot = rotation;
|
||||
placing = true;
|
||||
|
||||
if (item is ICustomHoldPivot)
|
||||
(item as ICustomHoldPivot).GetHoldPivot(out placeHandOffset, out placeHandRotation);
|
||||
else
|
||||
{
|
||||
placeHandOffset = Vector3.zero;
|
||||
placeHandRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
if (item is INicePlaceable placeable)
|
||||
placeable.OnStartedPlacing(this);
|
||||
else if (item is ISlottable slottable)
|
||||
slottable.OnStartedPlacing(this);
|
||||
|
||||
placingIsNice = placeT == null;
|
||||
placingIntoSlot = intoSlot;
|
||||
|
||||
// TODO: Add movement velocity to smoothing speed
|
||||
|
||||
placeStartTime = Time.time;
|
||||
|
||||
hand.parent = null;
|
||||
}
|
||||
|
||||
public void OverrideHandPositionAndRotation(Vector3 pos, Quaternion rot)
|
||||
{
|
||||
handTargetPos = pos;
|
||||
handTargetRot = rot;
|
||||
}
|
||||
|
||||
public void SetHandVelocity(Vector3 velo)
|
||||
{
|
||||
handRefVelo = velo;
|
||||
}
|
||||
|
||||
public void ResetOffset()
|
||||
{
|
||||
handTargetPos = handStartPos;
|
||||
handTargetRot = handStartRot;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (hand == null)
|
||||
hand = transform;
|
||||
|
||||
handStartPos = hand.transform.localPosition;
|
||||
handTargetPos = handStartPos;
|
||||
handStartRot = hand.transform.localRotation;
|
||||
handTargetRot = handStartRot;
|
||||
|
||||
if (lockableFreeLookComponent)
|
||||
{
|
||||
lockableFreeLook = lockableFreeLookComponent.GetComponent<ILockableFreeLook>();
|
||||
if (lockableFreeLook != null)
|
||||
Debug.Log("Found lockable free look on GameObject");
|
||||
}
|
||||
|
||||
if (focusEffectComponent)
|
||||
{
|
||||
focusableEffect = focusEffectComponent.GetComponent<IFocusableEffect>();
|
||||
if (focusableEffect != null)
|
||||
Debug.Log("Found focusable effect on GameObject");
|
||||
}
|
||||
|
||||
handParent = hand.parent;
|
||||
}
|
||||
|
||||
#region Update
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
public void UpdatePosition()
|
||||
{
|
||||
// sanity check
|
||||
if (item == null)
|
||||
if (placing)
|
||||
{
|
||||
this.EndPlacing();
|
||||
}
|
||||
|
||||
float dt = Time.deltaTime;
|
||||
mouseSpeed = new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0);
|
||||
|
||||
Vector3 targetPos = handTargetPos;
|
||||
|
||||
if (item is IOverrideHandPositon ohp)
|
||||
{
|
||||
targetPos = ohp.HandPosition;
|
||||
}
|
||||
|
||||
if (item is IOffsetHandPosition offhp)
|
||||
{
|
||||
targetPos += offhp.HandPositionOffset;
|
||||
}
|
||||
|
||||
float lrRot = (-0.5f + Mathf.PerlinNoise(Time.time * 3.34f, 0.234f)) * 5 * handNoiseGain;
|
||||
float udRot = (-0.5f + Mathf.PerlinNoise(Time.time * 3.34f, 34.783f)) * 5 * handNoiseGain;
|
||||
|
||||
Quaternion targetRot = handTargetRot * Quaternion.Euler(lrRot, udRot, 0);
|
||||
|
||||
if (placing)
|
||||
{
|
||||
// Get hold pivot offset and rotation
|
||||
Vector3 holdPos = Vector3.zero;
|
||||
Quaternion holdRot = Quaternion.identity;
|
||||
if (item is ICustomHoldPivot chp)
|
||||
{
|
||||
chp.GetHoldPivot(out holdPos, out holdRot);
|
||||
float slotScale = placeT ? 1.0f / placeT.lossyScale.x : 1;
|
||||
holdPos = holdPos * item.transform.lossyScale.x * slotScale;
|
||||
}
|
||||
|
||||
Vector3 placeWorldPos;
|
||||
Quaternion placeWorldRot;
|
||||
|
||||
if (!placeT) // calcaulte in world space
|
||||
{
|
||||
Matrix4x4 worldLocationMatrix = Matrix4x4.TRS(placeTLocalPos, placeTLocalRot, Vector3.one);
|
||||
Matrix4x4 handPivotMatrix = Matrix4x4.TRS(holdPos, holdRot, Vector3.one);
|
||||
Vector3 posOff = worldLocationMatrix * holdPos;
|
||||
|
||||
//var mat = handPivotMatrix * worldLocationMatrix;
|
||||
placeWorldPos = placeTLocalPos + (Vector3)(worldLocationMatrix * holdPos);
|
||||
placeWorldRot = placeTLocalRot * holdRot;
|
||||
//placeWorldRot = mat.rotation;
|
||||
}
|
||||
else // if placeT, calculate in local space of target object
|
||||
{
|
||||
placeWorldPos = placeT.TransformPoint(placeTLocalPos + holdPos);
|
||||
placeWorldRot = placeT.rotation * placeTLocalRot * holdRot;
|
||||
}
|
||||
|
||||
// Calculate targets in world space
|
||||
targetPos = placeWorldPos;
|
||||
targetRot = placeWorldRot;
|
||||
|
||||
bool isCloseToTarget = Vector3.Distance(hand.position, targetPos) < 0.02f;
|
||||
bool isAngleCloseToTarget = Quaternion.Angle(hand.rotation, targetRot) < 1;
|
||||
bool isSafetyTimeout = Time.time - placeStartTime > smoothPlaceTimeLimit;
|
||||
|
||||
// END PLACING
|
||||
if ((isCloseToTarget && isAngleCloseToTarget) || isSafetyTimeout)
|
||||
{
|
||||
EndPlacing();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Assign hand position and rotation:
|
||||
if (placing) // while placing is happening, lerping is in world space, otherwise it should be in localspace
|
||||
{
|
||||
hand.position = Vector3.SmoothDamp(hand.position, targetPos, ref handRefVelo, smoothMoveFactor);
|
||||
hand.rotation = Quaternion.Slerp(hand.rotation, targetRot, dt * smoothRotateRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
hand.localPosition = Vector3.SmoothDamp(hand.localPosition, targetPos, ref handRefVelo, smoothMoveFactor);
|
||||
hand.localRotation = Quaternion.Slerp(hand.localRotation, targetRot, dt * smoothRotateRate);
|
||||
}
|
||||
|
||||
if (examining)
|
||||
{
|
||||
if (itemInHands)
|
||||
{
|
||||
float x = mouseSpeed.x * examinationMouseSensitivity;
|
||||
float y = mouseSpeed.y * examinationMouseSensitivity;
|
||||
|
||||
IExaminable examinable = item as IExaminable;
|
||||
|
||||
if (examinable != null)
|
||||
{
|
||||
if (examinable.HorizontalAngle > 0)
|
||||
hand.Rotate(hand.transform.parent.up, x, Space.World);
|
||||
|
||||
if (examinable.VerticalAngle > 0)
|
||||
hand.Rotate(hand.transform.parent.right, y, Space.World);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EndPlacing()
|
||||
{
|
||||
placing = false;
|
||||
|
||||
// Temp, make it get velocity from target:
|
||||
handRefVelo = Vector3.zero;
|
||||
|
||||
var _item = itemInHands;
|
||||
if (_item != null)
|
||||
{
|
||||
DropFixed();
|
||||
_item.parent = placeT;
|
||||
_item.localPosition = placeTLocalPos;
|
||||
_item.localRotation = placeTLocalRot;
|
||||
}
|
||||
else Debug.LogError("Ending placement but item was null! This shouldn't happen");
|
||||
|
||||
if (placingIsNice && _item.GetComponent<Interactable>() is INicePlaceable placeable)
|
||||
placeable.OnNicePlaced(this);
|
||||
|
||||
//Debug.Log("Ending placeming");
|
||||
if (placingIntoSlot != null)
|
||||
Debug.Log("PLACINGINTOSLOT");
|
||||
|
||||
if (placingIntoSlot != null && _item.GetComponent<ISlottable>() != null)
|
||||
placingIntoSlot.SetItemInSlot(_item.GetComponent<ISlottable>());
|
||||
|
||||
placeT = null;
|
||||
placingIsNice = false;
|
||||
|
||||
hand.parent = handParent;
|
||||
}
|
||||
|
||||
//bool gunning = false;
|
||||
//public Transform gunningThing;
|
||||
|
||||
public struct HandsInput
|
||||
{
|
||||
public bool useDown;
|
||||
public bool useUp;
|
||||
public bool examineDown;
|
||||
public bool examineUp;
|
||||
public bool throwDown;
|
||||
public bool throwUp;
|
||||
public bool dropDown;
|
||||
public bool placeDown;
|
||||
}
|
||||
|
||||
HandsInput input;
|
||||
|
||||
public void SetInput(HandsInput input)
|
||||
{
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
public void UpdateInteraction()
|
||||
{
|
||||
#region Unused
|
||||
/*
|
||||
if (input.examineDown)
|
||||
{
|
||||
if (!gunning)
|
||||
{
|
||||
gunning = true;
|
||||
OverrideHandPositionAndRotation(Vector3.forward * 0.3f, Quaternion.LookRotation(-Vector3.right + Vector3.forward * 0.4f));
|
||||
GetComponent<InteractionController>().SetRayMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
gunning = false;
|
||||
ResetOffset();
|
||||
GetComponent<InteractionController>().SetRayMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
gunningThing.localPosition = Vector3.Lerp(gunningThing.localPosition, !gunning ? Vector3.down : Vector3.zero, Time.deltaTime * 10);
|
||||
*/
|
||||
|
||||
// RMB
|
||||
/*
|
||||
if (input.useDown)
|
||||
{
|
||||
if (item is ISecondaryUsable usable)
|
||||
{
|
||||
usable.UseSecondary();
|
||||
|
||||
if (usable.AllowExamination)
|
||||
StartAim();
|
||||
}
|
||||
else if (item is IExaminable examinable)
|
||||
{
|
||||
StartAim();
|
||||
}
|
||||
}*/
|
||||
#endregion
|
||||
|
||||
if (placing)
|
||||
return;
|
||||
|
||||
// RMB up
|
||||
if (input.examineUp)
|
||||
{
|
||||
EndAim();
|
||||
}
|
||||
if (input.useDown)
|
||||
{
|
||||
if (item is IUsable usable)
|
||||
usable.Use();
|
||||
}
|
||||
|
||||
if (input.useUp && item is IHoldUsable holdUsable)
|
||||
{
|
||||
holdUsable.UseEnd();
|
||||
}
|
||||
|
||||
if (Input.mouseScrollDelta.y != 0)
|
||||
{
|
||||
if (item is IScrollableInHand scrollable)
|
||||
scrollable.ScrollInHand(Input.mouseScrollDelta.y);
|
||||
}
|
||||
|
||||
if (input.dropDown && item is IDroppable)
|
||||
{
|
||||
IDroppable droppable = item as IDroppable;
|
||||
droppable.OnDropped(this);
|
||||
|
||||
if (!droppable.DelayDrop)
|
||||
Drop();
|
||||
}
|
||||
|
||||
if (input.throwDown && item is IThrowable)
|
||||
{
|
||||
IThrowable throwable = item as IThrowable;
|
||||
|
||||
if (throwFromCenter)
|
||||
{
|
||||
hand.localPosition = new Vector3(0, 0, hand.localPosition.z);
|
||||
|
||||
if (throwTransform)
|
||||
hand.position = throwTransform.position;
|
||||
}
|
||||
|
||||
Drop();
|
||||
throwable.OnDropped(this);
|
||||
|
||||
Vector3 throwFrw = throwTransform ? throwTransform.forward : transform.forward;
|
||||
|
||||
float throwSpeed = throwable.minThrowAcceleration;
|
||||
Vector3 force = throwFrw * throwSpeed + Vector3.up * throwUpFactor;
|
||||
|
||||
throwable.Rigidbody.AddForce(force, ForceMode.VelocityChange);
|
||||
throwable.Rigidbody.AddTorque(transform.forward * throwAngularVelocity, ForceMode.VelocityChange);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Aiming
|
||||
|
||||
bool examining;
|
||||
|
||||
void StartAim()
|
||||
{
|
||||
examining = true;
|
||||
|
||||
if (item && item is ICustomExaminePosition cep)
|
||||
handTargetPos = cep.ExaminePosition;
|
||||
else
|
||||
handTargetPos = handAimPos;
|
||||
|
||||
handTargetRot = Quaternion.identity;
|
||||
|
||||
LockFreeLook(true);
|
||||
focusableEffect?.FocusEffect(true, handTargetPos.z);
|
||||
}
|
||||
|
||||
void EndAim()
|
||||
{
|
||||
examining = false;
|
||||
|
||||
if (item && item is ICustomHandPosition chp)
|
||||
handTargetPos = chp.HandsOffset;
|
||||
else
|
||||
handTargetPos = handStartPos;
|
||||
|
||||
handTargetRot = handStartRot;
|
||||
|
||||
LockFreeLook(false);
|
||||
focusableEffect?.FocusEffect(false, 1000);
|
||||
}
|
||||
|
||||
public void LockFreeLook(bool b)
|
||||
{
|
||||
if (mouseLooks != null)
|
||||
for (int i = 0; i < mouseLooks.Length; i++)
|
||||
mouseLooks[i].enabled = !b;
|
||||
|
||||
lockableFreeLook?.LockFreeLook(b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Items/Hands.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Items/Hands.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff7c610785ea24144a1af4b97eb2ba39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
196
Assets/Plugins/Interaction/Runtime/Items/Slot.cs
Normal file
196
Assets/Plugins/Interaction/Runtime/Items/Slot.cs
Normal file
@ -0,0 +1,196 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Nothke.Interaction.Items;
|
||||
using Nothke.Interaction.UI;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public class Slot : Interactable, IItemReceivable, IItemInHandsInteractionDependable
|
||||
{
|
||||
public Transform slotPivot;
|
||||
|
||||
public string slotTag;
|
||||
public virtual string SlotTag => slotTag;
|
||||
|
||||
public ISlottable itemInSlot;
|
||||
public bool Occupied => itemInSlot != null;
|
||||
|
||||
public override string Label
|
||||
{
|
||||
get
|
||||
{
|
||||
if (itemInSlot != null)
|
||||
return (itemInSlot as Interactable).Label;
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Awake()
|
||||
{
|
||||
if (slotPivot.IsNonUniform())
|
||||
Debug.LogError("Slot lossy scale is not uniform, this is not allowed.", slotPivot);
|
||||
}
|
||||
#endif
|
||||
|
||||
public virtual bool IsInteractableIfHolding(Interactable item)
|
||||
{
|
||||
// if occupied and holding an item, not able to interact
|
||||
if (item != null && itemInSlot != null)
|
||||
return false;
|
||||
|
||||
// if occupied and not holding anything, able to take
|
||||
if (item == null && itemInSlot != null)
|
||||
return true;
|
||||
|
||||
var slottable = item as ISlottable;
|
||||
|
||||
if (slottable == null) return false;
|
||||
|
||||
if (!slottable.IsSlottable)
|
||||
return false;
|
||||
|
||||
if (CanReceive(slottable))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanReceive(ISlottable slottable)
|
||||
{
|
||||
if (itemInSlot != null) return false;
|
||||
|
||||
Debug.Assert(slottable != null, "CanReceive slottable is null");
|
||||
|
||||
if (slottable.SlotTag == SlotTag)
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public override void Use(InteractionController im)
|
||||
{
|
||||
manager = im;
|
||||
SlotOrTake(im);
|
||||
}
|
||||
|
||||
public void SlotOrTake(InteractionController im)
|
||||
{
|
||||
var hands = im.hands;
|
||||
|
||||
if (!hands.item && itemInSlot != null)
|
||||
{
|
||||
if (IsTakeable)
|
||||
Take();
|
||||
}
|
||||
else
|
||||
if (hands.item && hands.item is ISlottable)
|
||||
{
|
||||
SlotItemFromHands(hands);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsTakeable => true;
|
||||
|
||||
public void Take()
|
||||
{
|
||||
if (itemInSlot == null)
|
||||
{
|
||||
Debug.LogError("Attempting to take an item from slot but there is none");
|
||||
return;
|
||||
}
|
||||
|
||||
var takeable = itemInSlot as ITakeable;
|
||||
|
||||
Debug.Assert(takeable != null, "Item is slottable but not takeable", this);
|
||||
|
||||
OnBeforeTaken();
|
||||
|
||||
manager.hands.Take(takeable);
|
||||
|
||||
itemInSlot.OnRemovedFromSlot();
|
||||
itemInSlot.SlottedIn = null;
|
||||
itemInSlot = null;
|
||||
|
||||
manager.Recast();
|
||||
}
|
||||
|
||||
public void SlotItemFromHands(IHands hands)
|
||||
{
|
||||
if (CanReceive(hands.item as ISlottable))
|
||||
{
|
||||
manager.hands.Place(Vector3.zero, Quaternion.identity, slotPivot, this);
|
||||
|
||||
var item = hands.item;
|
||||
|
||||
// if not smooth placement:
|
||||
//itemInSlot = item as ISlottable;
|
||||
//itemInSlot.SlottedIn = this;
|
||||
//itemInSlot.OnSlotted();
|
||||
//OnSlot();
|
||||
|
||||
// if smooth placement, hands will callback the slot:
|
||||
(item as ISlottable).OnStartedPlacing(hands);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetItemInSlot(ISlottable item)
|
||||
{
|
||||
Debug.Assert(item != null, "ISlottable passed is null");
|
||||
//Debug.Log("Slotted " + (item as Component).gameObject.name + " into " + gameObject.name, this);
|
||||
|
||||
if (CanReceive(item))
|
||||
{
|
||||
var itemT = (item as Component).transform;
|
||||
itemT.parent = slotPivot;
|
||||
itemT.localPosition = Vector3.zero;
|
||||
itemT.localRotation = Quaternion.identity;
|
||||
|
||||
itemInSlot = item;
|
||||
item.SlottedIn = this;
|
||||
|
||||
item.OnSlotted();
|
||||
OnSlot();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Slot can't receive this item, tags don't match OR already holding item", item as Component);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (manager)
|
||||
manager.Recast();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ISlottable RemoveItemFromSlot()
|
||||
{
|
||||
var takeable = itemInSlot as ITakeable;
|
||||
|
||||
OnBeforeTaken();
|
||||
|
||||
var _item = itemInSlot;
|
||||
itemInSlot = null;
|
||||
|
||||
(_item as Component).transform.SetParent(null);
|
||||
_item.OnRemovedFromSlot();
|
||||
_item.SlottedIn = null;
|
||||
|
||||
return _item;
|
||||
}
|
||||
|
||||
public virtual void OnBeforeTaken() { }
|
||||
public virtual void OnSlot() { }
|
||||
|
||||
public ReticleUI.State GetCustomReticle()
|
||||
{
|
||||
if (itemInSlot != null)
|
||||
return ReticleUI.State.Take;
|
||||
else
|
||||
return ReticleUI.State.Slot;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Items/Slot.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Items/Slot.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 668243f6f6db5be499bd28639ba7c669
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Plugins/Interaction/Runtime/Items/Slots.cs
Normal file
32
Assets/Plugins/Interaction/Runtime/Items/Slots.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Nothke.Interaction.Items;
|
||||
|
||||
namespace Nothke.Interaction
|
||||
{
|
||||
public interface ISlottable
|
||||
{
|
||||
string SlotTag { get; }
|
||||
|
||||
bool IsSlottable { get; }
|
||||
void OnStartedPlacing(IHands hands);
|
||||
void OnSlotted();
|
||||
|
||||
IItemReceivable SlottedIn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called before IsSlottable is nulled
|
||||
/// </summary>
|
||||
void OnRemovedFromSlot();
|
||||
}
|
||||
|
||||
public interface IItemReceivable
|
||||
{
|
||||
string SlotTag { get; }
|
||||
|
||||
bool CanReceive(ISlottable slottable);
|
||||
bool SetItemInSlot(ISlottable slottable);
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Items/Slots.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Items/Slots.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8738e65b425e1df4492657193fd2b9fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Assets/Plugins/Interaction/Runtime/Nothke.Interaction.asmdef
Normal file
15
Assets/Plugins/Interaction/Runtime/Nothke.Interaction.asmdef
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Nothke.Interaction",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 902337b6423063d4693a927013a507f7
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/Rigidbody.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/Rigidbody.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa4d84620de80c74bad75c2327724d90
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
233
Assets/Plugins/Interaction/Runtime/Rigidbody/DragRigidbody.cs
Normal file
233
Assets/Plugins/Interaction/Runtime/Rigidbody/DragRigidbody.cs
Normal file
@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction.Items
|
||||
{
|
||||
/// <summary>
|
||||
/// Use this if mass of rigidbody changes while the rigidbody is being held
|
||||
/// </summary>
|
||||
public interface IDragRigidbodyReleaseMassSettable
|
||||
{
|
||||
float ReleaseMass { get; }
|
||||
}
|
||||
|
||||
public class DragRigidbody : MonoBehaviour
|
||||
{
|
||||
public static DragRigidbody e;
|
||||
private void Awake() { e = this; }
|
||||
|
||||
public float k_Spring = 50.0f;
|
||||
public float k_Damper = 5.0f;
|
||||
public float k_Drag = 0f;
|
||||
public float k_AngularDrag = 0.0f;
|
||||
public float k_Distance = 0.0001f;
|
||||
public bool k_AttachToCenterOfMass = false;
|
||||
|
||||
public float distanceLimit = 2;
|
||||
public float clampVelocity = 2;
|
||||
public float clampExitVelocity = 2;
|
||||
|
||||
public float fakeMass = 0;
|
||||
float originalMass;
|
||||
|
||||
Rigidbody body;
|
||||
private ConfigurableJoint joint;
|
||||
RigidbodyInterpolation originalInterpolation;
|
||||
|
||||
public bool Holding => joint && joint.connectedBody;
|
||||
|
||||
public event Action OnSlipped;
|
||||
|
||||
public bool Hitting { private set; get; }
|
||||
|
||||
float hitDistance;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CreateJoint();
|
||||
}
|
||||
|
||||
void CreateJoint()
|
||||
{
|
||||
var go = new GameObject("Rigidbody dragger");
|
||||
body = go.AddComponent<Rigidbody>();
|
||||
//body.rotation = Quaternion.LookRotation(transform.forward, transform.up);
|
||||
joint = go.AddComponent<ConfigurableJoint>();
|
||||
body.isKinematic = true;
|
||||
}
|
||||
|
||||
public float GetJointDistance()
|
||||
{
|
||||
if (joint && joint.connectedBody)
|
||||
return Vector3.Distance(
|
||||
body.position,
|
||||
joint.connectedBody.transform.TransformPoint(joint.connectedAnchor));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Quaternion addedRotation = Quaternion.identity;
|
||||
[NonSerialized] public bool rotate;
|
||||
[NonSerialized] public float rotateXInput;
|
||||
[NonSerialized] public float rotateYInput;
|
||||
|
||||
bool overrideTarget = false;
|
||||
Vector3 overrideTargetPoint;
|
||||
|
||||
public void OverrideTarget(Vector3 target)
|
||||
{
|
||||
overrideTarget = true;
|
||||
overrideTargetPoint = target;
|
||||
}
|
||||
|
||||
public void EndOverridingTarget()
|
||||
{
|
||||
overrideTarget = false;
|
||||
}
|
||||
|
||||
public Vector3 GetFrontTargetPoint()
|
||||
{
|
||||
return new Ray(transform.position, transform.forward).GetPoint(hitDistance);
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (joint && joint.connectedBody)
|
||||
{
|
||||
//var ray = new Ray(transform.position, transform.forward);
|
||||
|
||||
Vector3 targetPoint = overrideTarget ? overrideTargetPoint :
|
||||
GetFrontTargetPoint();
|
||||
//ray.GetPoint(hitDistance);
|
||||
|
||||
joint.transform.position = targetPoint;
|
||||
|
||||
//joint.connectedBody.velocity = Vector3.ClampMagnitude(joint.connectedBody.velocity, clampVelocity);
|
||||
//joint.targetRotation = transform.rotation;
|
||||
//joint.targetRotation = UnityEngine.Random.rotation;
|
||||
|
||||
var bodyRot = body.rotation;
|
||||
if (rotate)
|
||||
{
|
||||
float mx = rotateXInput * 10;
|
||||
float my = rotateYInput * 10;
|
||||
|
||||
addedRotation =
|
||||
Quaternion.AngleAxis(mx, Vector3.up) *
|
||||
Quaternion.AngleAxis(my, Vector3.right) * addedRotation;
|
||||
|
||||
|
||||
//addedRotation *= Quaternion.Euler(mx * 10, 0, my * 10);
|
||||
|
||||
//body.rotation = rot * addedRotation;
|
||||
//body.MoveRotation(rot * Quaternion.Euler(4, 0, 0));
|
||||
//joint.targetRotation = rot * Quaternion.Euler(4, 0, 0);
|
||||
}
|
||||
|
||||
//Quaternion faceTo = Quaternion.Inverse(transform.rotation) * Quaternion.Euler(0, 90, 0);
|
||||
//addedRotation = Quaternion.Slerp(addedRotation, faceTo, Time.deltaTime * 10);
|
||||
|
||||
body.rotation = transform.rotation * addedRotation;
|
||||
|
||||
if (GetJointDistance() > distanceLimit)
|
||||
{
|
||||
Slip();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void Slip()
|
||||
{
|
||||
End();
|
||||
|
||||
if (OnSlipped != null)
|
||||
OnSlipped();
|
||||
}
|
||||
|
||||
/*
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0) && joint && joint.connectedBody)
|
||||
End();
|
||||
}*/
|
||||
|
||||
public void Attach(RaycastHit hit, bool fixedRotation = true)
|
||||
{
|
||||
Attach(hit.rigidbody, hit.point, hit.distance, fixedRotation);
|
||||
}
|
||||
|
||||
public void Attach(Rigidbody rigidbody, Vector3 point, float distance, bool fixedRotation)
|
||||
{
|
||||
if (!joint) CreateJoint();
|
||||
|
||||
if (fakeMass > 0)
|
||||
{
|
||||
originalMass = rigidbody.mass;
|
||||
rigidbody.mass = fakeMass;
|
||||
}
|
||||
|
||||
originalInterpolation = rigidbody.interpolation;
|
||||
rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
|
||||
|
||||
joint.transform.position = point;
|
||||
joint.anchor = Vector3.zero;
|
||||
joint.transform.rotation = transform.rotation;
|
||||
//joint.targetRotation = Quaternion.identity;
|
||||
//joint.targetRotation = Quaternion.Inverse(transform.rotation);// Quaternion.LookRotation(transform.forward, transform.up);
|
||||
|
||||
joint.angularXMotion = joint.angularYMotion = joint.angularZMotion
|
||||
= fixedRotation ? ConfigurableJointMotion.Locked : ConfigurableJointMotion.Free;
|
||||
|
||||
JointDrive drive = new JointDrive();
|
||||
drive.positionSpring = k_Spring;
|
||||
drive.positionDamper = k_Damper;
|
||||
drive.maximumForce = Mathf.Infinity;
|
||||
|
||||
joint.xDrive = drive;
|
||||
joint.yDrive = drive;
|
||||
joint.zDrive = drive;
|
||||
|
||||
//joint.spring = k_Spring;
|
||||
//joint.damper = k_Damper;
|
||||
//joint.maxDistance = k_Distance;
|
||||
joint.connectedBody = rigidbody;
|
||||
|
||||
hitDistance = distance;
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
if (!joint.connectedBody)
|
||||
return;
|
||||
|
||||
if (fakeMass > 0)
|
||||
{
|
||||
var massSettable = joint.connectedBody.GetComponent<IDragRigidbodyReleaseMassSettable>();
|
||||
|
||||
if (massSettable != null)
|
||||
{
|
||||
joint.connectedBody.mass = massSettable.ReleaseMass;
|
||||
}
|
||||
else
|
||||
{
|
||||
joint.connectedBody.mass = originalMass;
|
||||
}
|
||||
}
|
||||
|
||||
joint.connectedBody.interpolation = originalInterpolation;
|
||||
|
||||
if (clampExitVelocity > 0)
|
||||
joint.connectedBody.velocity =
|
||||
Vector3.ClampMagnitude(joint.connectedBody.velocity, clampExitVelocity);
|
||||
|
||||
addedRotation = Quaternion.identity;
|
||||
|
||||
joint.connectedBody = null;
|
||||
|
||||
overrideTarget = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e26630301387ce5469cfa0fb478b201b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Interaction.Items
|
||||
{
|
||||
public class RigidbodyInteractable : Interactable
|
||||
{
|
||||
public Rigidbody rb;
|
||||
public bool rotateAroundPoint;
|
||||
|
||||
[System.NonSerialized]
|
||||
public bool held;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!rb)
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
public override void Use(InteractionController im)
|
||||
{
|
||||
base.Use(im);
|
||||
|
||||
DragRigidbody.e.Attach(im.hit, !rotateAroundPoint);
|
||||
DragRigidbody.e.OnSlipped += Unhold;
|
||||
}
|
||||
|
||||
public override void StartHold()
|
||||
{
|
||||
base.StartHold();
|
||||
manager.FreezeDetection();
|
||||
|
||||
held = true;
|
||||
|
||||
OnStartedHold();
|
||||
}
|
||||
|
||||
public override void EndHold()
|
||||
{
|
||||
base.EndHold();
|
||||
|
||||
if (!held)
|
||||
return;
|
||||
|
||||
DragRigidbody.e.End();
|
||||
|
||||
Unhold();
|
||||
}
|
||||
|
||||
void Unhold()
|
||||
{
|
||||
manager.UnfreezeDetection();
|
||||
manager.LockFreeLook(false);
|
||||
DragRigidbody.e.OnSlipped -= Unhold;
|
||||
held = false;
|
||||
OnEndedHold();
|
||||
}
|
||||
|
||||
protected virtual void OnStartedHold() { }
|
||||
protected virtual void OnEndedHold() { }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf9152fd8b7951445bef5e6f0778fd53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/UI.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/UI.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea81ead1b5cbf7845be57adbbba3ab98
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
176
Assets/Plugins/Interaction/Runtime/UI/InteractionUI.cs
Normal file
176
Assets/Plugins/Interaction/Runtime/UI/InteractionUI.cs
Normal file
@ -0,0 +1,176 @@
|
||||
#define CENTER_TEXT
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
#if CENTER_TEXT
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
using Nothke.Interaction.Items;
|
||||
|
||||
namespace Nothke.Interaction.UI
|
||||
{
|
||||
public interface ICustomReticle
|
||||
{
|
||||
ReticleUI.State GetCustomReticle();
|
||||
}
|
||||
|
||||
public interface IReticleUIOverridable
|
||||
{
|
||||
bool OverrideUI { get; }
|
||||
bool ReleaseInteractionBlocking { get; }
|
||||
}
|
||||
|
||||
public class InteractionUI : MonoBehaviour
|
||||
{
|
||||
public static InteractionUI e;
|
||||
private void Awake()
|
||||
{
|
||||
e = this;
|
||||
|
||||
controller = GetComponent<InteractionController>();
|
||||
if (!controller) controller = FindObjectOfType<InteractionController>();
|
||||
if (!controller)
|
||||
{
|
||||
Debug.LogError("No controller found");
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if CENTER_TEXT
|
||||
public TMP_Text centerText;
|
||||
#endif
|
||||
|
||||
InteractionController controller;
|
||||
|
||||
bool mouseRay;
|
||||
|
||||
RigidbodyInteractable riHovered;
|
||||
RigidbodyInteractable ri;
|
||||
|
||||
IReticleUIOverridable overridable;
|
||||
|
||||
bool ovrr;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
controller.OnHover += OnHover;
|
||||
controller.OnDehover += OnDehover;
|
||||
controller.OnRayModeChange += OnRayModeChange;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
controller.OnHover -= OnHover;
|
||||
controller.OnDehover -= OnDehover;
|
||||
controller.OnRayModeChange += OnRayModeChange;
|
||||
}
|
||||
|
||||
#if CENTER_TEXT
|
||||
public void SetText(string description)
|
||||
{
|
||||
centerText.enabled = true;
|
||||
centerText.text = description;
|
||||
}
|
||||
|
||||
public void HideText()
|
||||
{
|
||||
centerText.enabled = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void OnHover(Interactable interactable)
|
||||
{
|
||||
if (ovrr) return;
|
||||
|
||||
#if CENTER_TEXT
|
||||
if (centerText)
|
||||
{
|
||||
SetText(interactable.Label);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Interactable icon choice
|
||||
|
||||
if (interactable is ICustomReticle)
|
||||
{
|
||||
ReticleUI.state = (interactable as ICustomReticle).GetCustomReticle();
|
||||
}
|
||||
else if (interactable is ITakeable)
|
||||
{
|
||||
ReticleUI.state = ReticleUI.State.Take;
|
||||
}
|
||||
else if (interactable is RigidbodyInteractable)
|
||||
{
|
||||
ReticleUI.state = ReticleUI.State.Grab;
|
||||
|
||||
riHovered = interactable as RigidbodyInteractable;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReticleUI.state = ReticleUI.State.Idle;
|
||||
}
|
||||
|
||||
if (interactable is IReticleUIOverridable)
|
||||
{
|
||||
overridable = interactable as IReticleUIOverridable;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (overridable != null)
|
||||
{
|
||||
ovrr = overridable.OverrideUI;
|
||||
if (ovrr == false)
|
||||
{
|
||||
OnDehover();
|
||||
overridable = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (riHovered && riHovered.held && ri == null)
|
||||
{
|
||||
ri = riHovered;
|
||||
ovrr = true;
|
||||
ReticleUI.state = ReticleUI.State.Hold;
|
||||
}
|
||||
|
||||
if (ri && !ri.held)
|
||||
{
|
||||
ovrr = false;
|
||||
OnDehover();
|
||||
|
||||
if (controller.hovered)
|
||||
OnHover(controller.hovered);
|
||||
|
||||
ri = null;
|
||||
}
|
||||
|
||||
if (controller.mouseRay)
|
||||
{
|
||||
ReticleUI.SetReticlePosition(Input.mousePosition);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDehover()
|
||||
{
|
||||
if (ovrr) return;
|
||||
|
||||
#if CENTER_TEXT
|
||||
if (centerText)
|
||||
centerText.enabled = false;
|
||||
#endif
|
||||
|
||||
ReticleUI.state = ReticleUI.State.None;
|
||||
}
|
||||
|
||||
protected virtual void OnRayModeChange(bool enable)
|
||||
{
|
||||
if (!enable)
|
||||
ReticleUI.ResetReticlePosition();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/UI/InteractionUI.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/UI/InteractionUI.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81363621df3548e45ba871e78efd9d68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
95
Assets/Plugins/Interaction/Runtime/UI/ReticleUI.cs
Normal file
95
Assets/Plugins/Interaction/Runtime/UI/ReticleUI.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Nothke.Interaction.UI
|
||||
{
|
||||
public class ReticleUI : MonoBehaviour
|
||||
{
|
||||
static ReticleUI e;
|
||||
private void Awake() { e = this; }
|
||||
|
||||
public bool showIconForNone;
|
||||
|
||||
public Texture icon_none;
|
||||
public Texture icon_generic;
|
||||
public Texture icon_grab;
|
||||
public Texture icon_hold;
|
||||
public Texture icon_take;
|
||||
public Texture icon_slot;
|
||||
|
||||
public Texture icon_ride;
|
||||
public Texture icon_scroll;
|
||||
public Texture icon_grab_knob;
|
||||
public Texture icon_hold_knob;
|
||||
|
||||
public RawImage image;
|
||||
|
||||
public enum State { None, Idle, Grab, Hold, Take, Slot, Ride, Scroll, GrabKnob, HoldKnob }
|
||||
public static State state;
|
||||
static State lastState;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private void Init()
|
||||
{
|
||||
state = State.None;
|
||||
lastState = State.None;
|
||||
}
|
||||
|
||||
public static void Hide()
|
||||
{
|
||||
state = State.None;
|
||||
e.SetState();
|
||||
}
|
||||
|
||||
public static void ResetReticlePosition()
|
||||
{
|
||||
if (!e) return;
|
||||
RectTransform t = e.image.GetComponent<RectTransform>();
|
||||
t.anchoredPosition = Vector2.zero;
|
||||
}
|
||||
|
||||
public static void SetReticlePosition(Vector2 screenPos)
|
||||
{
|
||||
if (!e) return;
|
||||
RectTransform t = e.image.GetComponent<RectTransform>();
|
||||
t.position = screenPos;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetState();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (state != lastState)
|
||||
SetState();
|
||||
|
||||
lastState = state;
|
||||
}
|
||||
|
||||
void SetState()
|
||||
{
|
||||
if (!showIconForNone)
|
||||
image.enabled = state != State.None;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case State.None: image.texture = icon_none; break;
|
||||
case State.Idle: image.texture = icon_generic; break;
|
||||
case State.Grab: image.texture = icon_grab; break;
|
||||
case State.Hold: image.texture = icon_hold; break;
|
||||
case State.Take: image.texture = icon_take; break;
|
||||
case State.Slot: image.texture = icon_slot; break;
|
||||
|
||||
case State.Ride: image.texture = icon_ride; break;
|
||||
case State.Scroll: image.texture = icon_scroll; break;
|
||||
case State.GrabKnob: image.texture = icon_grab_knob; break;
|
||||
case State.HoldKnob: image.texture = icon_hold_knob; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/UI/ReticleUI.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/UI/ReticleUI.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f225472c8049dc418e5a37e0cf6e0e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Runtime/Utils.meta
Normal file
8
Assets/Plugins/Interaction/Runtime/Utils.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a221522d7b5de645a6de4380762b321
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
113
Assets/Plugins/Interaction/Runtime/Utils/BoundsUtils.cs
Normal file
113
Assets/Plugins/Interaction/Runtime/Utils/BoundsUtils.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Utils
|
||||
{
|
||||
public static class BoundsUtils
|
||||
{
|
||||
// static list for caching, never deallocates
|
||||
static List<Collider> colliderCache = new List<Collider>();
|
||||
|
||||
public static Bounds GetObjectSpaceColliderBounds(GameObject go, bool includeInactive = false)
|
||||
{
|
||||
Transform t = go.transform;
|
||||
var rootW2L = t.worldToLocalMatrix;
|
||||
|
||||
go.GetComponentsInChildren(includeInactive, colliderCache);
|
||||
|
||||
if (colliderCache.Count == 0)
|
||||
{
|
||||
Debug.LogError("Attempting to get bounds of the object but it has no colliders");
|
||||
return default;
|
||||
}
|
||||
|
||||
Bounds goBounds = GetBoundsInRootSpace(colliderCache[0]);
|
||||
|
||||
for (int i = 1; i < colliderCache.Count; i++)
|
||||
{
|
||||
Bounds b = GetBoundsInRootSpace(colliderCache[i]);
|
||||
goBounds.Encapsulate(b);
|
||||
}
|
||||
|
||||
return goBounds;
|
||||
|
||||
Bounds GetBoundsInRootSpace(Collider col)
|
||||
{
|
||||
Bounds b = col.GetLocalBounds();
|
||||
Matrix4x4 l2w = col.transform.localToWorldMatrix;
|
||||
Matrix4x4 local = rootW2L * l2w;
|
||||
return TransformBounds(local, b);
|
||||
}
|
||||
}
|
||||
|
||||
public static Bounds GetLocalBounds(this Collider collider)
|
||||
{
|
||||
if (collider is BoxCollider)
|
||||
{
|
||||
BoxCollider box = (BoxCollider)collider;
|
||||
return new Bounds(box.center, box.size);
|
||||
}
|
||||
else if (collider is SphereCollider)
|
||||
{
|
||||
var center = ((SphereCollider)collider).center;
|
||||
var radius = ((SphereCollider)collider).radius;
|
||||
Vector3 size = new Vector3(radius * 2, radius * 2, radius * 2);
|
||||
return new Bounds(center, size);
|
||||
}
|
||||
else if (collider is CapsuleCollider)
|
||||
{
|
||||
var capsule = (CapsuleCollider)collider;
|
||||
var r = capsule.radius;
|
||||
var h = capsule.height;
|
||||
|
||||
Vector3 size;
|
||||
switch (capsule.direction)
|
||||
{
|
||||
case 0: size = new Vector3(h, r * 2, r * 2); break;
|
||||
case 1: size = new Vector3(r * 2, h, r * 2); break;
|
||||
case 2: size = new Vector3(r * 2, r * 2, h); break;
|
||||
default: size = default; break;
|
||||
}
|
||||
|
||||
return new Bounds(capsule.center, size);
|
||||
}
|
||||
else if (collider is MeshCollider)
|
||||
{
|
||||
return ((MeshCollider)collider).sharedMesh.bounds;
|
||||
}
|
||||
|
||||
Debug.LogError("Attempting to get bounds of an unknown collider type");
|
||||
return new Bounds();
|
||||
}
|
||||
|
||||
public static Bounds TransformBounds(in Matrix4x4 mat, in Bounds bounds)
|
||||
{
|
||||
// Find 8 corners of the bounds
|
||||
Vector3 p0 = bounds.min;
|
||||
Vector3 p1 = bounds.max;
|
||||
Vector3 p2 = new Vector3(p0.x, p0.y, p1.z);
|
||||
Vector3 p3 = new Vector3(p0.x, p1.y, p0.z);
|
||||
Vector3 p4 = new Vector3(p1.x, p0.y, p0.z);
|
||||
Vector3 p5 = new Vector3(p0.x, p1.y, p1.z);
|
||||
Vector3 p6 = new Vector3(p1.x, p0.y, p1.z);
|
||||
Vector3 p7 = new Vector3(p1.x, p1.y, p0.z);
|
||||
|
||||
Bounds b = new Bounds(mat * p0, Vector3.zero);
|
||||
b.Encapsulate(mat * p1);
|
||||
b.Encapsulate(mat * p2);
|
||||
b.Encapsulate(mat * p3);
|
||||
b.Encapsulate(mat * p4);
|
||||
b.Encapsulate(mat * p5);
|
||||
b.Encapsulate(mat * p6);
|
||||
b.Encapsulate(mat * p7);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
public static void DrawBoundsGizmos(in Bounds bounds)
|
||||
{
|
||||
Gizmos.DrawWireCube(bounds.center, bounds.size);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Utils/BoundsUtils.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Utils/BoundsUtils.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10dcd8226f4ab2d498599806ceaf4ed7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Plugins/Interaction/Runtime/Utils/HandSway.cs
Normal file
32
Assets/Plugins/Interaction/Runtime/Utils/HandSway.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Utils
|
||||
{
|
||||
public class HandSway : MonoBehaviour
|
||||
{
|
||||
public float springRate = 10;
|
||||
public float softClampAngle = 30;
|
||||
|
||||
Quaternion lastRotation;
|
||||
|
||||
void Update()
|
||||
{
|
||||
Quaternion target = transform.parent.rotation;
|
||||
|
||||
lastRotation = Quaternion.Slerp(lastRotation, target, Time.deltaTime * springRate);
|
||||
lastRotation = SoftClampRotation(target, lastRotation, softClampAngle);
|
||||
|
||||
transform.rotation = lastRotation;
|
||||
}
|
||||
|
||||
public static Quaternion SoftClampRotation(Quaternion origin, Quaternion target, float limitAngleDegrees)
|
||||
{
|
||||
float angle = Quaternion.Angle(origin, target);
|
||||
float softAngle = Mathf.Atan(angle * Mathf.PI / 2 / limitAngleDegrees) / Mathf.PI * 2 * limitAngleDegrees;
|
||||
|
||||
return Quaternion.RotateTowards(origin, target, softAngle); // note: uses degrees
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/Interaction/Runtime/Utils/HandSway.cs.meta
Normal file
11
Assets/Plugins/Interaction/Runtime/Utils/HandSway.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5fc4a4111f27864b8128645cf6c82b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
89
Assets/Plugins/Interaction/Runtime/Utils/ObjectPreviewer.cs
Normal file
89
Assets/Plugins/Interaction/Runtime/Utils/ObjectPreviewer.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nothke.Utils
|
||||
{
|
||||
public static class ObjectPreviewer
|
||||
{
|
||||
struct Node
|
||||
{
|
||||
public Matrix4x4 transform;
|
||||
public Mesh mesh;
|
||||
public Material[] mats;
|
||||
}
|
||||
|
||||
// Static cache
|
||||
static List<MeshFilter> meshFiltersBuffer;
|
||||
static List<Node> nodes;
|
||||
|
||||
/// <summary>
|
||||
/// For performance reasons, the cache never deallocates.
|
||||
/// So, call this to clear the cache only in the case the memory becomes a problem, such as with previewing objects with gigantic hierarchies.
|
||||
/// (but even if they're gigantic it's quite unlikely it will be a problem)
|
||||
/// </summary>
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
public static void ReloadCache()
|
||||
{
|
||||
meshFiltersBuffer = new List<MeshFilter>();
|
||||
nodes = new List<Node>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assigns object for rendering. Call this only once on preview object change. Pass null to clear the object.
|
||||
/// </summary>
|
||||
public static void SetObject(GameObject go)
|
||||
{
|
||||
nodes.Clear();
|
||||
meshFiltersBuffer.Clear();
|
||||
|
||||
if (go == null)
|
||||
return;
|
||||
|
||||
Matrix4x4 rootW2L = go.transform.worldToLocalMatrix;
|
||||
// We need to scale in case the root has non 1,1,1 scale
|
||||
Matrix4x4 rootScaleMatrix = Matrix4x4.Scale(go.transform.localScale);
|
||||
go.transform.GetComponentsInChildren(meshFiltersBuffer);
|
||||
|
||||
foreach (var mf in meshFiltersBuffer)
|
||||
{
|
||||
Mesh mesh = mf.sharedMesh;
|
||||
var mr = mf.GetComponent<MeshRenderer>();
|
||||
|
||||
if (mesh == null)
|
||||
continue;
|
||||
|
||||
// Un-transform by root
|
||||
Matrix4x4 matrix = rootW2L * mf.transform.localToWorldMatrix * rootScaleMatrix;
|
||||
|
||||
Material[] mats = null;
|
||||
if (mr != null)
|
||||
mats = mr.sharedMaterials;
|
||||
|
||||
nodes.Add(new Node()
|
||||
{
|
||||
mesh = mesh,
|
||||
transform = matrix,
|
||||
mats = mats,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the preview object set with SetObject(). Call this every frame you want the object to be drawn.
|
||||
/// </summary>
|
||||
/// <param name="overrideMaterial">The replacement material that the previews will be drawn with. If not assigned, it will use the original material.</param>
|
||||
public static void Render(Vector3 position, Quaternion rotation, Vector3 scale, Material overrideMaterial = null, int renderLayer = 0)
|
||||
{
|
||||
Matrix4x4 previewTransform = Matrix4x4.TRS(position, rotation, scale);
|
||||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
for (int subMeshIndex = 0; subMeshIndex < node.mesh.subMeshCount; subMeshIndex++)
|
||||
{
|
||||
var mat = overrideMaterial != null ? overrideMaterial : node.mats[Mathf.Clamp(subMeshIndex, 0, node.mats.Length)];
|
||||
Graphics.DrawMesh(node.mesh, previewTransform * node.transform, mat, renderLayer, null, subMeshIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29d83e488182f784fb842823c959439b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Sample.meta
Normal file
8
Assets/Plugins/Interaction/Sample.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2d824383e2b705459ee4bf127a4687c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/Sample/Art.meta
Normal file
8
Assets/Plugins/Interaction/Sample/Art.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e461af23d489719408b14414d2e4f3aa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_circle.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_circle.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_circle.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_circle.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ae9c70fdf0754e4b8a3899fe78cf4a2
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_dot.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_dot.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_dot.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_dot.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3f4a03cbb6c2834cb8d594236317c99
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_drive.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_drive.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_drive.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_drive.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9e024d86f3328d46b6b65f82d46d471
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_hand.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_hand.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_hand.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_hand.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29bcd55e61ee51240bc7b3338592f8f0
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_hold.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_hold.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_hold.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_hold.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ea0dbfdc11a38d48937b187123b1d69
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_slot.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_slot.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_slot.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_slot.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acbdd4ec64e5a2f419f4f50231ec2135
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_yoke.png
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/Interaction/Sample/Art/reticle_yoke.png
(Stored with Git LFS)
Normal file
Binary file not shown.
104
Assets/Plugins/Interaction/Sample/Art/reticle_yoke.png.meta
Normal file
104
Assets/Plugins/Interaction/Sample/Art/reticle_yoke.png.meta
Normal file
@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cab33deb6d00fd43b66788b223d7cbd
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,365 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8184360672608164086
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8184360672608164091}
|
||||
- component: {fileID: 8184360672608164090}
|
||||
- component: {fileID: 8184360672608164089}
|
||||
- component: {fileID: 8184360672608164088}
|
||||
- component: {fileID: 8184360672608164087}
|
||||
m_Layer: 5
|
||||
m_Name: Example Interaction Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8184360672608164091
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672608164086}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_Children:
|
||||
- {fileID: 8184360673128861479}
|
||||
- {fileID: 8184360672637931736}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!223 &8184360672608164090
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672608164086}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &8184360672608164089
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672608164086}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
--- !u!114 &8184360672608164088
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672608164086}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &8184360672608164087
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672608164086}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 81363621df3548e45ba871e78efd9d68, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
centerText: {fileID: 8184360673128861477}
|
||||
--- !u!1 &8184360672637931735
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8184360672637931736}
|
||||
- component: {fileID: 8184360672637931738}
|
||||
- component: {fileID: 8184360672637931737}
|
||||
- component: {fileID: 8184360672637931739}
|
||||
m_Layer: 5
|
||||
m_Name: Reticle
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8184360672637931736
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672637931735}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8184360672608164091}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 32, y: 32}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8184360672637931738
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672637931735}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &8184360672637931737
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672637931735}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Texture: {fileID: 2800000, guid: d3f4a03cbb6c2834cb8d594236317c99, type: 3}
|
||||
m_UVRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
--- !u!114 &8184360672637931739
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360672637931735}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3f225472c8049dc418e5a37e0cf6e0e8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
showIconForNone: 1
|
||||
icon_none: {fileID: 2800000, guid: d3f4a03cbb6c2834cb8d594236317c99, type: 3}
|
||||
icon_generic: {fileID: 2800000, guid: 3ae9c70fdf0754e4b8a3899fe78cf4a2, type: 3}
|
||||
icon_grab: {fileID: 2800000, guid: 29bcd55e61ee51240bc7b3338592f8f0, type: 3}
|
||||
icon_hold: {fileID: 2800000, guid: 5ea0dbfdc11a38d48937b187123b1d69, type: 3}
|
||||
icon_take: {fileID: 2800000, guid: 29bcd55e61ee51240bc7b3338592f8f0, type: 3}
|
||||
icon_slot: {fileID: 2800000, guid: acbdd4ec64e5a2f419f4f50231ec2135, type: 3}
|
||||
icon_ride: {fileID: 2800000, guid: f9e024d86f3328d46b6b65f82d46d471, type: 3}
|
||||
image: {fileID: 8184360672637931737}
|
||||
--- !u!1 &8184360673128861476
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8184360673128861479}
|
||||
- component: {fileID: 8184360673128861478}
|
||||
- component: {fileID: 8184360673128861477}
|
||||
m_Layer: 5
|
||||
m_Name: Item Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8184360673128861479
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360673128861476}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8184360672608164091}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0}
|
||||
m_AnchorMax: {x: 0.5, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 106}
|
||||
m_SizeDelta: {x: 200, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!222 &8184360673128861478
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360673128861476}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &8184360673128861477
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8184360673128861476}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: Item Text
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_outlineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4278190080
|
||||
m_fontSize: 36
|
||||
m_fontSizeBase: 36
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_textAlignment: 514
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_firstOverflowCharacterIndex: -1
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
m_isLinkedTextComponent: 0
|
||||
m_isTextTruncated: 0
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_ignoreRectMaskCulling: 0
|
||||
m_ignoreCulling: 1
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_VertexBufferAutoSizeReduction: 1
|
||||
m_firstVisibleCharacter: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_textInfo:
|
||||
textComponent: {fileID: 8184360673128861477}
|
||||
characterCount: 9
|
||||
spriteCount: 0
|
||||
spaceCount: 1
|
||||
wordCount: 2
|
||||
linkCount: 0
|
||||
lineCount: 1
|
||||
pageCount: 1
|
||||
materialCount: 1
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_spriteAnimator: {fileID: 0}
|
||||
m_hasFontAssetChanged: 0
|
||||
m_subTextObjects:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 222bdbca0de25cf4e91591bd07d6587c
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Interaction/package.json
Normal file
8
Assets/Plugins/Interaction/package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "nothke.interaction",
|
||||
"displayName": "Nothke's Interaction",
|
||||
"version": "1.0.0",
|
||||
"unity": "2018.1",
|
||||
"description": "Interaction",
|
||||
"type": "library"
|
||||
}
|
7
Assets/Plugins/Interaction/package.json.meta
Normal file
7
Assets/Plugins/Interaction/package.json.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eca1d15c8646b8645b3b91a8b3f6eb9c
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -13,6 +13,7 @@ GameObject:
|
||||
- component: {fileID: 2547041061673746692}
|
||||
- component: {fileID: 3271489653354074546}
|
||||
- component: {fileID: 6230516344177671089}
|
||||
- component: {fileID: 2268654696567863074}
|
||||
m_Layer: 0
|
||||
m_Name: crate_test
|
||||
m_TagString: Untagged
|
||||
@ -133,3 +134,20 @@ Rigidbody:
|
||||
m_Interpolate: 1
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &2268654696567863074
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8661871210265028242}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cf9152fd8b7951445bef5e6f0778fd53, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
manager: {fileID: 0}
|
||||
info:
|
||||
name:
|
||||
rb: {fileID: 0}
|
||||
rotateAroundPoint: 0
|
||||
|
File diff suppressed because it is too large
Load Diff
8
Assets/Scripts/Interactables.meta
Normal file
8
Assets/Scripts/Interactables.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 433e1012444d2b845ba4765ede367e22
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Assets/Scripts/Interactables/InteractableTest.cs
Normal file
13
Assets/Scripts/Interactables/InteractableTest.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Nothke.Interaction;
|
||||
|
||||
public class InteractableTest : Interactable
|
||||
{
|
||||
public override void Use(InteractionController im)
|
||||
{
|
||||
base.Use(im);
|
||||
Debug.Log("works!");
|
||||
}
|
||||
}
|
11
Assets/Scripts/Interactables/InteractableTest.cs.meta
Normal file
11
Assets/Scripts/Interactables/InteractableTest.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 429d0776ebbb12d4e8adc0328a254f36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -11,15 +11,20 @@ public class SlidingCrane : MonoBehaviour
|
||||
public Transform xTransform;
|
||||
public Transform yTransform;
|
||||
|
||||
|
||||
public float yRange = 10;
|
||||
public float xRange = 5;
|
||||
|
||||
public Transform testTgt;
|
||||
public Vector3 target;
|
||||
|
||||
public Rigidbody craneRail ;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
target = transform.position;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
@ -30,7 +35,6 @@ public class SlidingCrane : MonoBehaviour
|
||||
|
||||
Vector3 localTarget = transform.InverseTransformPoint(target);
|
||||
|
||||
|
||||
Vector2 targetPlanar = new Vector2(localTarget.x, localTarget.z);
|
||||
|
||||
float xTgt = Mathf.InverseLerp(-xRange, xRange, targetPlanar.x);
|
||||
|
114
Assets/Textures/hammer.png.meta
Normal file
114
Assets/Textures/hammer.png.meta
Normal file
@ -0,0 +1,114 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb6bad4174f45d645b4a8e7b6746e030
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -3,7 +3,7 @@
|
||||
--- !u!5 &1
|
||||
TimeManager:
|
||||
m_ObjectHideFlags: 0
|
||||
Fixed Timestep: 0.02
|
||||
Fixed Timestep: 0.01
|
||||
Maximum Allowed Timestep: 0.33333334
|
||||
m_TimeScale: 1
|
||||
Maximum Particle Timestep: 0.03
|
||||
|
Loading…
Reference in New Issue
Block a user