Skip to content

Commit

Permalink
Apply fixes from MARS Companion project--mostly fixes for null refs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtschoen-unity committed Aug 28, 2020
1 parent ef892f1 commit b0262ff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,15 @@ public override void Process()

var usedEvent = SendUpdateEventToSelectedObject();

// Position the event camera to cast physics rays
if (m_EventCamera != null)
{
var eventCameraTransform = m_EventCamera.transform;
var mainCameraTransform = m_MainCamera.transform;
eventCameraTransform.position = mainCameraTransform.position;
eventCameraTransform.rotation = mainCameraTransform.rotation;
}

// case 1004066 - touch / mouse events should be processed before navigation events in case
// they change the current selected gameobject and the submit button is a touch / mouse button.

Expand All @@ -495,12 +504,6 @@ public override void Process()

bool ProcessTouchEvents()
{
// Position the event camera to cast physics rays
var eventCameraTransform = m_EventCamera.transform;
var mainCameraTransform = m_MainCamera.transform;
eventCameraTransform.position = mainCameraTransform.position;
eventCameraTransform.rotation = mainCameraTransform.rotation;

for (var i = 0; i < input.touchCount; ++i)
{
var touch = input.GetTouch(i);
Expand Down Expand Up @@ -720,12 +723,6 @@ protected void ProcessMouseEvent()
/// </summary>
protected void ProcessMouseEvent(int id)
{
// Position the event camera to cast physics rays
var eventCameraTransform = m_EventCamera.transform;
var mainCameraTransform = m_MainCamera.transform;
eventCameraTransform.position = mainCameraTransform.position;
eventCameraTransform.rotation = mainCameraTransform.rotation;

var mouseData = GetMouseRayEventData(id);
var leftButtonData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ abstract class RayInputModule : BaseInputModule, IUsesViewerScale
// Local method use only -- created here to reduce garbage collection
RayEventData m_TempRayEvent;

protected override void Awake()

protected override void OnEnable()
{
base.Awake();
base.OnEnable();
m_TempRayEvent = new RayEventData(eventSystem);
}

Expand Down
3 changes: 3 additions & 0 deletions Runtime/Scripts/Modules/SnappingModule/SnappingModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ public void OnDeserializePreferences(object obj)

public void OnBehaviorUpdate()
{
if (m_ModuleParent == null)
return;

if (snappingEnabled)
{
var camera = CameraUtils.GetMainCamera();
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Tools/TransformTool/TransformTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void Start()

public void OnSelectionChanged()
{
if (!this.IsSharedUpdater(this))
if (!this.IsSharedUpdater(this) || !m_CurrentManipulator)
return;

if (Selection.gameObjects.Length == 0)
Expand Down

0 comments on commit b0262ff

Please sign in to comment.