Skip to content

Commit

Permalink
Extract far interactor visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
FejZa committed Jun 20, 2024
1 parent 7a66dba commit 621fa22
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 192 deletions.
62 changes: 62 additions & 0 deletions Assets~/StandardAssets/Interactors/LineInteractorVisualizer.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,68 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a0c2a07ed1df1094ba9ac469febef61e, type: 3}
m_Name:
m_EditorClassIdentifier:
lineBase: {fileID: 4233110557611249510}
defaultLineColor:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_ColorSpace: -1
m_NumColorKeys: 2
m_NumAlphaKeys: 2
lineColorInputDown:
serializedVersion: 2
key0: {r: 0, g: 0.9806142, b: 1, a: 0}
key1: {r: 0, g: 0.9806142, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 1}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 3277
atime2: 49151
atime3: 65535
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_ColorSpace: -1
m_NumColorKeys: 2
m_NumAlphaKeys: 4
lineCastResolution: 2
--- !u!114 &4233110557611249510
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
36 changes: 30 additions & 6 deletions Runtime/Input/Interactors/BaseControllerInteractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ public abstract class BaseControllerInteractor : ControllerPoseSynchronizer, ICo
/// </summary>
protected bool IsSelectPressed { get; set; } = false;

/// <summary>
/// <c>true</c>, if any <see cref="InputAction"/> is down on this <see cref="IInteractor"/>.
/// </summary>
protected bool IsInputDown => inputDownActions.Count > 0;
/// <inheritdoc />
public bool IsInputDown => inputDownActions.Count > 0;

/// <summary>
/// True if select has been pressed once since this component was enabled
Expand Down Expand Up @@ -387,6 +385,11 @@ protected override void Start()
{
base.Start();
SetCursor();

if (visualizer.IsNotNull())
{
visualizer.Interactor = this;
}
}

/// <inheritdoc/>
Expand Down Expand Up @@ -422,12 +425,34 @@ protected override void OnDisable()
}
}

/// <inheritdoc/>
protected override void OnDestroy()
{
if (visualizer.IsNotNull())
{
visualizer.gameObject.Destroy();
}

base.OnDestroy();
}

/// <inheritdoc />
public virtual void OnPreRaycast() { }
public virtual void OnPreRaycast()
{
if (visualizer.IsNotNull())
{
visualizer.OnPreRaycast();
}
}

/// <inheritdoc />
public virtual void OnPostRaycast()
{
if (visualizer.IsNotNull())
{
visualizer.OnPostRaycast();
}

if (grabAction != InputAction.None)
{
if (IsGrabPressed)
Expand All @@ -440,7 +465,6 @@ public virtual void OnPostRaycast()
if (IsSelectPressed)
{
DragHandler(pointerAction);

}
}
}
Expand Down
7 changes: 7 additions & 0 deletions Runtime/Input/Interactors/BaseInteractorVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace RealityToolkit.Input.Interactors
{
public abstract class BaseInteractorVisualizer : MonoBehaviour, IInteractorVisualizer
{
/// <inheritdoc />
public virtual IInteractor Interactor { get; set; }

/// <inheritdoc />
public virtual void OnPreRaycast() { }

/// <inheritdoc />
public virtual void OnPostRaycast() { }
}
}
Loading

0 comments on commit 621fa22

Please sign in to comment.