Skip to content

Commit

Permalink
Rename miniWorldHasObject to miniWorldRayHasObject; Adjust comment wo…
Browse files Browse the repository at this point in the history
…rding;

Clean up formatting
  • Loading branch information
mtschoen-unity committed Sep 23, 2016
1 parent e2131ea commit 1564f89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions Scripts/EditorVR.cs
Expand Up @@ -191,7 +191,7 @@ private void OnSceneGUI(EditorWindow obj)
{
if (Event.current.type == EventType.MouseMove)
{
var miniWorldHasObject = false;
var miniWorldRayHasObject = false;

foreach (var proxy in m_AllProxies)
{
Expand All @@ -206,13 +206,13 @@ private void OnSceneGUI(EditorWindow obj)
miniWorldRay.Value.hoverObject = m_PixelRaycastModule.UpdateRaycast(miniWorldRay.Key, m_EventCamera, GetPointerLength(miniWorldRay.Key));

if (miniWorldRay.Value.hoverObject || miniWorldRay.Value.dragObject)
miniWorldHasObject = true;
miniWorldRayHasObject = true;
}
}

// If any active miniWorldRay hovers over a selected object, switch to the DirectManipulator
if (m_TransformTool != null)
m_TransformTool.mode = miniWorldHasObject ? TransformMode.Direct : TransformMode.Standard;
m_TransformTool.mode = miniWorldRayHasObject ? TransformMode.Direct : TransformMode.Standard;

UpdateDefaultProxyRays();
}
Expand Down Expand Up @@ -996,13 +996,13 @@ private void UpdateMiniWorldRays()
var isContained = miniWorld.Contains(originalRayOrigin.position + originalRayOrigin.forward * pointerLength);
miniWorldRayOrigin.gameObject.SetActive(isContained);

// Deactivate ActionMapInput if the ray is not inside a MiniWorld or currently dragging an object
// Keep input alive if we are dragging an object, otherwise MultipleRayInputModule will reset our control state
ray.Value.uiInput.active = isContained || ray.Value.dragObject;

var uiInput = (UIActions)ray.Value.uiInput;
var hoverObject = ray.Value.hoverObject;

// Start dragging if we're hoving over a selected object, dragObject is null, and the trigger is held
// Instead of using wasJustPressed, use isHeld to allow dragging with a single press
if (hoverObject && Selection.gameObjects.Contains(hoverObject) && !ray.Value.dragObject && uiInput.select.isHeld)
{
//Disable original ray so that it doesn't interrupt dragging by activating its ActionMapInput
Expand All @@ -1021,7 +1021,7 @@ private void UpdateMiniWorldRays()
if (uiInput.@select.isHeld)
{
var selectedObjectTransform = ray.Value.dragObject.transform;
// If the pointer is inside the MiniWorld, position at an offset from controller positoin
// If the pointer is inside the MiniWorld, position at an offset from controller position
if (ray.Key.gameObject.activeSelf)
{
selectedObjectTransform.localScale = ray.Value.dragObjectOriginalScale;
Expand All @@ -1031,8 +1031,6 @@ private void UpdateMiniWorldRays()
// If the object is outside, attach to controller as a preview
else
{
Selection.objects = new UnityEngine.Object[0];

m_ObjectPlacementModule.PositionPreview(selectedObjectTransform, GetPreviewOriginForRayOrigin(originalRayOrigin));

selectedObjectTransform.transform.localScale = Vector3.one;
Expand Down
2 changes: 1 addition & 1 deletion Tools/TransformTool/TransformTool.cs
Expand Up @@ -55,7 +55,6 @@ public TransformMode mode
}
}
}

private TransformMode m_Mode;

public ActionMapInput actionMapInput { get { return m_TransformInput; } set { m_TransformInput = (TransformInput) value; } }
Expand Down Expand Up @@ -92,6 +91,7 @@ void Update()
{
if (m_Mode == TransformMode.Direct)
return;

if (m_SelectionTransforms != null && m_SelectionTransforms.Length > 0)
{
if (m_TransformInput.pivotMode.wasJustPressed) // Switching center vs pivot
Expand Down

0 comments on commit 1564f89

Please sign in to comment.