From 43eaa870e1a1cd39285c1bf9c68ac6757bb7d92b Mon Sep 17 00:00:00 2001 From: "Simon (Darkside) Jackson" Date: Thu, 7 Mar 2019 18:11:51 +0000 Subject: [PATCH] Resolved a number of .NET warnings and invalid properties --- .../01_Basic/Example01Scene.cs | 2 +- .../01_Basic/Example01ScrollView.cs | 2 +- .../01_Basic/Example01ScrollViewCell.cs | 4 +- .../02_CellEventHandling/Example02Scene.cs | 2 +- .../Example02ScrollView.cs | 2 +- .../Example02ScrollViewCell.cs | 8 +- .../03_InfiniteScroll/Example03Scene.cs | 2 +- .../03_InfiniteScroll/Example03ScrollView.cs | 2 +- .../Example03ScrollViewCell.cs | 8 +- .../04_FocusOn/Example04Scene.cs | 8 +- .../04_FocusOn/Example04ScrollView.cs | 2 +- .../04_FocusOn/Example04ScrollViewCell.cs | 8 +- Scripts/Controls/BoxSlider.cs | 8 +- .../ColorPicker/ColorPickerControl.cs | 2 +- Scripts/Effects/UIParticleSystem.cs | 4 +- .../Layout/CardUI/2D Cards/CardExpanding2D.cs | 20 ++--- Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs | 2 +- Scripts/Layout/CardUI/2D Cards/CardStack2D.cs | 2 +- Scripts/Layout/ContentScrollSnapHorizontal.cs | 86 +++++++++---------- Scripts/Layout/FancyScrollView.cs | 10 +-- Scripts/Layout/ScrollPositionController.cs | 2 +- Scripts/Utilities/UIScrollToSelectionXY.cs | 9 +- Scripts/VR Extensions/VRInputModule.cs | 14 +-- 23 files changed, 104 insertions(+), 105 deletions(-) diff --git a/Examples/FancyScrollView/01_Basic/Example01Scene.cs b/Examples/FancyScrollView/01_Basic/Example01Scene.cs index 10411cd..a1574e3 100644 --- a/Examples/FancyScrollView/01_Basic/Example01Scene.cs +++ b/Examples/FancyScrollView/01_Basic/Example01Scene.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example01Scene : MonoBehaviour { [SerializeField] - Example01ScrollView scrollView; + Example01ScrollView scrollView = null; void Start() { diff --git a/Examples/FancyScrollView/01_Basic/Example01ScrollView.cs b/Examples/FancyScrollView/01_Basic/Example01ScrollView.cs index 3172daf..807dcc2 100644 --- a/Examples/FancyScrollView/01_Basic/Example01ScrollView.cs +++ b/Examples/FancyScrollView/01_Basic/Example01ScrollView.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example01ScrollView : FancyScrollView { [SerializeField] - ScrollPositionController scrollPositionController; + ScrollPositionController scrollPositionController = null; void Awake() { diff --git a/Examples/FancyScrollView/01_Basic/Example01ScrollViewCell.cs b/Examples/FancyScrollView/01_Basic/Example01ScrollViewCell.cs index 0c88d85..1da329b 100644 --- a/Examples/FancyScrollView/01_Basic/Example01ScrollViewCell.cs +++ b/Examples/FancyScrollView/01_Basic/Example01ScrollViewCell.cs @@ -6,9 +6,9 @@ namespace UnityEngine.UI.Extensions.Examples public class Example01ScrollViewCell : FancyScrollViewCell { [SerializeField] - Animator animator; + Animator animator = null; [SerializeField] - Text message; + Text message = null; static readonly int scrollTriggerHash = Animator.StringToHash("scroll"); diff --git a/Examples/FancyScrollView/02_CellEventHandling/Example02Scene.cs b/Examples/FancyScrollView/02_CellEventHandling/Example02Scene.cs index cb19b0b..a68331b 100644 --- a/Examples/FancyScrollView/02_CellEventHandling/Example02Scene.cs +++ b/Examples/FancyScrollView/02_CellEventHandling/Example02Scene.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example02Scene : MonoBehaviour { [SerializeField] - Example02ScrollView scrollView; + Example02ScrollView scrollView = null; void Start() { diff --git a/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollView.cs b/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollView.cs index 7e5b4fa..d1a98ee 100644 --- a/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollView.cs +++ b/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollView.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example02ScrollView : FancyScrollView { [SerializeField] - ScrollPositionController scrollPositionController; + ScrollPositionController scrollPositionController = null; void Awake() { diff --git a/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollViewCell.cs b/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollViewCell.cs index fff127f..4a84ea4 100644 --- a/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollViewCell.cs +++ b/Examples/FancyScrollView/02_CellEventHandling/Example02ScrollViewCell.cs @@ -6,13 +6,13 @@ namespace UnityEngine.UI.Extensions.Examples public class Example02ScrollViewCell : FancyScrollViewCell { [SerializeField] - Animator animator; + Animator animator = null; [SerializeField] - Text message; + Text message = null; [SerializeField] - Image image; + Image image = null; [SerializeField] - Button button; + Button button = null; static readonly int scrollTriggerHash = Animator.StringToHash("scroll"); diff --git a/Examples/FancyScrollView/03_InfiniteScroll/Example03Scene.cs b/Examples/FancyScrollView/03_InfiniteScroll/Example03Scene.cs index b70126d..6f710c6 100644 --- a/Examples/FancyScrollView/03_InfiniteScroll/Example03Scene.cs +++ b/Examples/FancyScrollView/03_InfiniteScroll/Example03Scene.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example03Scene : MonoBehaviour { [SerializeField] - Example03ScrollView scrollView; + Example03ScrollView scrollView = null; void Start() { diff --git a/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollView.cs b/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollView.cs index ea20097..4d18c7a 100644 --- a/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollView.cs +++ b/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollView.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example03ScrollView : FancyScrollView { [SerializeField] - ScrollPositionController scrollPositionController; + ScrollPositionController scrollPositionController = null; void Awake() { diff --git a/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollViewCell.cs b/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollViewCell.cs index 99739ee..9d37e3a 100644 --- a/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollViewCell.cs +++ b/Examples/FancyScrollView/03_InfiniteScroll/Example03ScrollViewCell.cs @@ -6,13 +6,13 @@ namespace UnityEngine.UI.Extensions.Examples public class Example03ScrollViewCell : FancyScrollViewCell { [SerializeField] - Animator animator; + Animator animator = null; [SerializeField] - Text message; + Text message = null; [SerializeField] - Image image; + Image image = null; [SerializeField] - Button button; + Button button = null; static readonly int scrollTriggerHash = Animator.StringToHash("scroll"); diff --git a/Examples/FancyScrollView/04_FocusOn/Example04Scene.cs b/Examples/FancyScrollView/04_FocusOn/Example04Scene.cs index 6d98901..11e2caa 100644 --- a/Examples/FancyScrollView/04_FocusOn/Example04Scene.cs +++ b/Examples/FancyScrollView/04_FocusOn/Example04Scene.cs @@ -8,13 +8,13 @@ namespace UnityEngine.UI.Extensions.Examples public class Example04Scene : MonoBehaviour { [SerializeField] - Example04ScrollView scrollView; + Example04ScrollView scrollView = null; [SerializeField] - Button prevCellButton; + Button prevCellButton = null; [SerializeField] - Button nextCellButton; + Button nextCellButton = null; [SerializeField] - Text selectedItemInfo; + Text selectedItemInfo = null; void Start() { diff --git a/Examples/FancyScrollView/04_FocusOn/Example04ScrollView.cs b/Examples/FancyScrollView/04_FocusOn/Example04ScrollView.cs index 0540ebb..16f3de0 100644 --- a/Examples/FancyScrollView/04_FocusOn/Example04ScrollView.cs +++ b/Examples/FancyScrollView/04_FocusOn/Example04ScrollView.cs @@ -7,7 +7,7 @@ namespace UnityEngine.UI.Extensions.Examples public class Example04ScrollView : FancyScrollView { [SerializeField] - ScrollPositionController scrollPositionController; + ScrollPositionController scrollPositionController = null; Action onSelectedIndexChanged; diff --git a/Examples/FancyScrollView/04_FocusOn/Example04ScrollViewCell.cs b/Examples/FancyScrollView/04_FocusOn/Example04ScrollViewCell.cs index 5e33e83..8d5de36 100644 --- a/Examples/FancyScrollView/04_FocusOn/Example04ScrollViewCell.cs +++ b/Examples/FancyScrollView/04_FocusOn/Example04ScrollViewCell.cs @@ -6,13 +6,13 @@ namespace UnityEngine.UI.Extensions.Examples public class Example04ScrollViewCell : FancyScrollViewCell { [SerializeField] - Animator animator; + Animator animator = null; [SerializeField] - Text message; + Text message = null; [SerializeField] - Image image; + Image image = null; [SerializeField] - Button button; + Button button = null; static readonly int scrollTriggerHash = Animator.StringToHash("scroll"); diff --git a/Scripts/Controls/BoxSlider.cs b/Scripts/Controls/BoxSlider.cs index 57dee94..dca4608 100644 --- a/Scripts/Controls/BoxSlider.cs +++ b/Scripts/Controls/BoxSlider.cs @@ -298,8 +298,12 @@ namespace UnityEngine.UI.Extensions anchorMin[0] = anchorMax[0] = (NormalizedValueX); anchorMin[1] = anchorMax[1] = (NormalizedValueY); - m_HandleRect.anchorMin = anchorMin; - m_HandleRect.anchorMax = anchorMax; + if (Application.isPlaying) + { + m_HandleRect.anchorMin = anchorMin; + m_HandleRect.anchorMax = anchorMax; + } + } } diff --git a/Scripts/Controls/ColorPicker/ColorPickerControl.cs b/Scripts/Controls/ColorPicker/ColorPickerControl.cs index bebcc8b..e9b9f69 100644 --- a/Scripts/Controls/ColorPicker/ColorPickerControl.cs +++ b/Scripts/Controls/ColorPicker/ColorPickerControl.cs @@ -33,7 +33,7 @@ namespace UnityEngine.UI.Extensions.ColorPicker List rgbSliders = new List(); [SerializeField] - GameObject alphaSlider; + GameObject alphaSlider = null; public void SetHSVSlidersOn(bool value) { diff --git a/Scripts/Effects/UIParticleSystem.cs b/Scripts/Effects/UIParticleSystem.cs index c448cce..beaaf4d 100644 --- a/Scripts/Effects/UIParticleSystem.cs +++ b/Scripts/Effects/UIParticleSystem.cs @@ -371,8 +371,8 @@ namespace UnityEngine.UI.Extensions pSystem = null; Initialize(); } - - void OnDestroy() + + protected override void OnDestroy() { currentMaterial = null; currentTexture = null; diff --git a/Scripts/Layout/CardUI/2D Cards/CardExpanding2D.cs b/Scripts/Layout/CardUI/2D Cards/CardExpanding2D.cs index 9b73534..ca61ed5 100644 --- a/Scripts/Layout/CardUI/2D Cards/CardExpanding2D.cs +++ b/Scripts/Layout/CardUI/2D Cards/CardExpanding2D.cs @@ -17,22 +17,22 @@ public class CardExpanding2D : MonoBehaviour private float lerpSpeed = 8f; [SerializeField] - private RectTransform buttonRect; - private Vector2 closeButtonMin; - private Vector2 closeButtonMax; + private RectTransform buttonRect = null; + private Vector2 closeButtonMin = Vector2.zero; + private Vector2 closeButtonMax = Vector2.zero; [SerializeField] - private Vector2 cardSize; + private Vector2 cardSize = Vector2.zero; [SerializeField] - private Vector2 pageSize; + private Vector2 pageSize = Vector2.zero; - private Vector2 cardCenter; + private Vector2 cardCenter = Vector2.zero; private Vector2 pageCenter = Vector2.zero; - private Vector2 cardMin; - private Vector2 cardMax; - private Vector2 pageMin; - private Vector2 pageMax; + private Vector2 cardMin = Vector2.zero; + private Vector2 cardMax = Vector2.zero; + private Vector2 pageMin = Vector2.zero; + private Vector2 pageMax = Vector2.zero; private RectTransform rectTrans; ///I wouldn't recommend changing animationActive's value here unless you want the card to start as a page. diff --git a/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs b/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs index 3678403..14ce789 100644 --- a/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs +++ b/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs @@ -18,7 +18,7 @@ public class CardPopup2D : MonoBehaviour [SerializeField] private float centeringSpeed = 4f; [SerializeField] - private bool singleScene; + private bool singleScene = false; private Rigidbody rbody; private bool isFalling; diff --git a/Scripts/Layout/CardUI/2D Cards/CardStack2D.cs b/Scripts/Layout/CardUI/2D Cards/CardStack2D.cs index 2865327..b38059c 100644 --- a/Scripts/Layout/CardUI/2D Cards/CardStack2D.cs +++ b/Scripts/Layout/CardUI/2D Cards/CardStack2D.cs @@ -25,7 +25,7 @@ public class CardStack2D : MonoBehaviour [SerializeField] private int usedCardXPos = 1280; [SerializeField] - private Transform[] cards; + private Transform[] cards = null; private int cardArrayOffset; private Vector3[] cardPositions; diff --git a/Scripts/Layout/ContentScrollSnapHorizontal.cs b/Scripts/Layout/ContentScrollSnapHorizontal.cs index 948ffa9..4e7ae27 100644 --- a/Scripts/Layout/ContentScrollSnapHorizontal.cs +++ b/Scripts/Layout/ContentScrollSnapHorizontal.cs @@ -39,7 +39,7 @@ namespace UnityEngine.UI.Extensions [SerializeField] [Tooltip("Event is triggered whenever the scroll rect starts to move, even when triggered programatically")] private StartMovementEvent m_StartMovementEvent = new StartMovementEvent(); - public StartMovementEvent startMovementEvent + public StartMovementEvent MovementStarted { get { @@ -54,7 +54,7 @@ namespace UnityEngine.UI.Extensions [SerializeField] [Tooltip("Event is triggered whenever the closest item to the center of the scrollrect changes")] private CurrentItemChangeEvent m_CurrentItemChangeEvent = new CurrentItemChangeEvent(); - public CurrentItemChangeEvent currentItemChangeEvent + public CurrentItemChangeEvent CurrentItemChanged { get { @@ -69,7 +69,7 @@ namespace UnityEngine.UI.Extensions [SerializeField] [Tooltip("Event is triggered when the ContentSnapScroll decides which item it is going to snap to. Returns the index of the closest position.")] private FoundItemToSnapToEvent m_FoundItemToSnapToEvent = new FoundItemToSnapToEvent(); - public FoundItemToSnapToEvent foundItemToSnapToEvent + public FoundItemToSnapToEvent ItemFoundToSnap { get { @@ -84,7 +84,7 @@ namespace UnityEngine.UI.Extensions [SerializeField] [Tooltip("Event is triggered when we finally settle on an element. Returns the index of the item's position.")] private SnappedToItemEvent m_SnappedToItemEvent = new SnappedToItemEvent(); - public SnappedToItemEvent snappedToItemEvent + public SnappedToItemEvent ItemSnappedTo { get { @@ -96,20 +96,18 @@ namespace UnityEngine.UI.Extensions } } - private ScrollRect scrollRect; - private RectTransform scrollRectTransform; - private RectTransform contentTransform; - private List contentPositions; - private Vector3 lerpTarget; - private float totalScrollableWidth; - private DrivenRectTransformTracker tracker; - private bool lerp; - private float mLerpTime; - private int _closestItem; - private bool lerpToContentRunning; - private bool mSliding; - private bool mLerping; - private bool contentIsHorizonalLayoutGroup + private ScrollRect scrollRect = null; + private RectTransform scrollRectTransform = null; + private RectTransform contentTransform = null; + private List contentPositions = null; + private Vector3 lerpTarget = Vector3.zero; + private float totalScrollableWidth = 0; + private DrivenRectTransformTracker tracker ; + private float mLerpTime = 0; + private int _closestItem = 0; + private bool mSliding = false; + private bool mLerping = false; + private bool ContentIsHorizonalLayoutGroup { get { @@ -121,18 +119,18 @@ namespace UnityEngine.UI.Extensions /// /// Returns if the SnapScroll is moving /// - public bool moving + public bool Moving { get { - return sliding || lerping; + return Sliding || Lerping; } } /// /// Returns if the SnapScroll is moving because of a touch /// - public bool sliding + public bool Sliding { get { @@ -142,7 +140,7 @@ namespace UnityEngine.UI.Extensions /// /// Returns if the SnapScroll is moving programmatically /// - public bool lerping + public bool Lerping { get { @@ -154,7 +152,7 @@ namespace UnityEngine.UI.Extensions /// Returns the closest item's index /// *Note this is zero based, and based on position not child order /// - public int closestItemIndex + public int ClosestItemIndex { get { @@ -165,7 +163,7 @@ namespace UnityEngine.UI.Extensions /// Returns the lerpTarget's index /// *Note this is zero-based, and based on position not child order /// - public int lerpTargetIndex + public int LerpTargetIndex { get { @@ -216,7 +214,7 @@ namespace UnityEngine.UI.Extensions private void SetupSnapScroll() { - if (contentIsHorizonalLayoutGroup) + if (ContentIsHorizonalLayoutGroup) { //because you can't get the anchored positions of UI elements //when they are in a layout group (as far as I could tell) @@ -320,9 +318,9 @@ namespace UnityEngine.UI.Extensions /// All of the info about how you want it to move public void GoTo(MoveInfo info) { - if (!moving && info.index != closestItemIndex) + if (!Moving && info.index != ClosestItemIndex) { - startMovementEvent.Invoke(); + MovementStarted.Invoke(); } if (info.indexType == MoveInfo.IndexType.childIndex) @@ -341,7 +339,7 @@ namespace UnityEngine.UI.Extensions { int clampedIndex = Mathf.Clamp(index, 0, contentPositions.Count - 1); //contentPositions amount == the amount of available children - if (contentIsHorizonalLayoutGroup) //the contentPositions are in child order + if (ContentIsHorizonalLayoutGroup) //the contentPositions are in child order { lerpTarget = contentPositions[clampedIndex]; if (jump) @@ -408,13 +406,13 @@ namespace UnityEngine.UI.Extensions public void NextItem() { int index; - if (sliding) + if (Sliding) { - index = closestItemIndex + 1; + index = ClosestItemIndex + 1; } else { - index = lerpTargetIndex + 1; + index = LerpTargetIndex + 1; } MoveInfo info = new MoveInfo(MoveInfo.IndexType.positionIndex, index, jumpToItem, lerpTime); GoTo(info); @@ -427,13 +425,13 @@ namespace UnityEngine.UI.Extensions public void PreviousItem() { int index; - if (sliding) + if (Sliding) { - index = closestItemIndex - 1; + index = ClosestItemIndex - 1; } else { - index = lerpTargetIndex - 1; + index = LerpTargetIndex - 1; } MoveInfo info = new MoveInfo(MoveInfo.IndexType.positionIndex, index, jumpToItem, lerpTime); GoTo(info); @@ -464,9 +462,9 @@ namespace UnityEngine.UI.Extensions public void OnBeginDrag(PointerEventData ped) { StopMovement(); - if (!moving) + if (!Moving) { - startMovementEvent.Invoke(); + MovementStarted.Invoke(); } } @@ -477,11 +475,11 @@ namespace UnityEngine.UI.Extensions private void Update() { - if (_closestItem != closestItemIndex) + if (_closestItem != ClosestItemIndex) { - currentItemChangeEvent.Invoke(closestItemIndex); - ChangePaginationInfo(closestItemIndex); - _closestItem = closestItemIndex; + CurrentItemChanged.Invoke(ClosestItemIndex); + ChangePaginationInfo(ClosestItemIndex); + _closestItem = ClosestItemIndex; } } @@ -494,7 +492,7 @@ namespace UnityEngine.UI.Extensions } lerpTarget = FindClosestFrom(contentTransform.localPosition); - foundItemToSnapToEvent.Invoke(lerpTargetIndex); + ItemFoundToSnap.Invoke(LerpTargetIndex); while (Vector3.Distance(contentTransform.localPosition, lerpTarget) > 1) { @@ -504,12 +502,12 @@ namespace UnityEngine.UI.Extensions mSliding = false; scrollRect.velocity = Vector2.zero; contentTransform.localPosition = lerpTarget; - snappedToItemEvent.Invoke(lerpTargetIndex); + ItemSnappedTo.Invoke(LerpTargetIndex); } private IEnumerator LerpToContent() { - foundItemToSnapToEvent.Invoke(lerpTargetIndex); + ItemFoundToSnap.Invoke(LerpTargetIndex); mLerping = true; Vector3 originalContentPos = contentTransform.localPosition; float elapsedTime = 0; @@ -519,7 +517,7 @@ namespace UnityEngine.UI.Extensions contentTransform.localPosition = Vector3.Lerp(originalContentPos, lerpTarget, (elapsedTime / mLerpTime)); yield return null; } - snappedToItemEvent.Invoke(lerpTargetIndex); + ItemSnappedTo.Invoke(LerpTargetIndex); mLerping = false; } #endregion diff --git a/Scripts/Layout/FancyScrollView.cs b/Scripts/Layout/FancyScrollView.cs index b4dad0e..1321307 100644 --- a/Scripts/Layout/FancyScrollView.cs +++ b/Scripts/Layout/FancyScrollView.cs @@ -8,15 +8,15 @@ namespace UnityEngine.UI.Extensions public abstract class FancyScrollView : MonoBehaviour where TContext : class { [SerializeField, Range(float.Epsilon, 1f)] - float cellInterval; + float cellInterval = 0; [SerializeField, Range(0f, 1f)] - float cellOffset; + float cellOffset = 0; [SerializeField] - bool loop; + bool loop = false; [SerializeField] - GameObject cellBase; + GameObject cellBase = null; [SerializeField] - Transform cellContainer; + Transform cellContainer = null; readonly List> cells = new List>(); float currentPosition; diff --git a/Scripts/Layout/ScrollPositionController.cs b/Scripts/Layout/ScrollPositionController.cs index 9163e00..eb9c4ef 100644 --- a/Scripts/Layout/ScrollPositionController.cs +++ b/Scripts/Layout/ScrollPositionController.cs @@ -10,7 +10,7 @@ namespace UnityEngine.UI.Extensions public class ScrollPositionController : UIBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler { [SerializeField] - RectTransform viewport; + RectTransform viewport = null; [SerializeField] ScrollDirection directionOfRecognize = ScrollDirection.Vertical; [SerializeField] diff --git a/Scripts/Utilities/UIScrollToSelectionXY.cs b/Scripts/Utilities/UIScrollToSelectionXY.cs index 59da619..1ca0208 100644 --- a/Scripts/Utilities/UIScrollToSelectionXY.cs +++ b/Scripts/Utilities/UIScrollToSelectionXY.cs @@ -29,9 +29,8 @@ namespace UnityEngine.UI.Extensions private bool scrollToSelection = true; // references - private RectTransform scrollWindow; - private RectTransform currentCanvas; - private ScrollRect targetScrollRect; + private RectTransform scrollWindow = null; + private ScrollRect targetScrollRect = null; #endregion // Use this for initialization @@ -85,8 +84,6 @@ namespace UnityEngine.UI.Extensions // move the current scroll rect to correct position float selectionPos = -selection.anchoredPosition.y; - //float elementHeight = layoutListGroup.sizeDelta.y / layoutListGroup.transform.childCount; - //float maskHeight = currentCanvas.sizeDelta.y + scrollWindow.sizeDelta.y; float listPixelAnchor = layoutListGroup.anchoredPosition.y; // get the element offset value depending on the cursor move direction @@ -104,8 +101,6 @@ namespace UnityEngine.UI.Extensions // move the current scroll rect to correct position float selectionPos = -selection.anchoredPosition.x; - //float elementWidth = layoutListGroup.sizeDelta.x / layoutListGroup.transform.childCount; - //float maskWidth = currentCanvas.sizeDelta.y + scrollWindow.sizeDelta.y; float listPixelAnchor = layoutListGroup.anchoredPosition.x; // get the element offset value depending on the cursor move direction diff --git a/Scripts/VR Extensions/VRInputModule.cs b/Scripts/VR Extensions/VRInputModule.cs index b78de0c..25a1c86 100644 --- a/Scripts/VR Extensions/VRInputModule.cs +++ b/Scripts/VR Extensions/VRInputModule.cs @@ -12,8 +12,6 @@ namespace UnityEngine.UI.Extensions static VRInputModule _singleton; - private int counter; - private static bool mouseClicked; public static Vector3 cursorPosition; @@ -38,8 +36,10 @@ namespace UnityEngine.UI.Extensions if (mouseClicked) { //BaseEventData data = GetBaseEventData(); //Original from Process(). Can't be called here so is replaced by the next line: - BaseEventData data = new BaseEventData(_singleton.eventSystem); - data.selectedObject = targetObject; + BaseEventData data = new BaseEventData(_singleton.eventSystem) + { + selectedObject = targetObject + }; ExecuteEvents.Execute(targetObject, data, ExecuteEvents.submitHandler); print("clicked " + targetObject.name); mouseClicked = false; @@ -57,8 +57,10 @@ namespace UnityEngine.UI.Extensions public static void PointerEnter(GameObject obj) { print("PointerEnter " + obj.name); - PointerEventData pEvent = new PointerEventData(_singleton.eventSystem); - pEvent.pointerEnter = obj; + PointerEventData pEvent = new PointerEventData(_singleton.eventSystem) + { + pointerEnter = obj + }; RaycastResult rcr = new RaycastResult() { worldPosition = cursorPosition }; pEvent.pointerCurrentRaycast = rcr; ExecuteEvents.Execute(obj, pEvent, ExecuteEvents.pointerEnterHandler);