Resolved a number of .NET warnings and invalid properties

pull/413/head
Simon (Darkside) Jackson 2019-03-07 18:11:51 +00:00
parent 22b2ec2ec2
commit 43eaa870e1
23 changed files with 104 additions and 105 deletions

View File

@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example01Scene : MonoBehaviour
{
[SerializeField]
Example01ScrollView scrollView;
Example01ScrollView scrollView = null;
void Start()
{

View File

@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example01ScrollView : FancyScrollView<Example01CellDto>
{
[SerializeField]
ScrollPositionController scrollPositionController;
ScrollPositionController scrollPositionController = null;
void Awake()
{

View File

@ -6,9 +6,9 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example01ScrollViewCell : FancyScrollViewCell<Example01CellDto>
{
[SerializeField]
Animator animator;
Animator animator = null;
[SerializeField]
Text message;
Text message = null;
static readonly int scrollTriggerHash = Animator.StringToHash("scroll");

View File

@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example02Scene : MonoBehaviour
{
[SerializeField]
Example02ScrollView scrollView;
Example02ScrollView scrollView = null;
void Start()
{

View File

@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example02ScrollView : FancyScrollView<Example02CellDto, Example02ScrollViewContext>
{
[SerializeField]
ScrollPositionController scrollPositionController;
ScrollPositionController scrollPositionController = null;
void Awake()
{

View File

@ -6,13 +6,13 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example02ScrollViewCell : FancyScrollViewCell<Example02CellDto, Example02ScrollViewContext>
{
[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");

View File

@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example03Scene : MonoBehaviour
{
[SerializeField]
Example03ScrollView scrollView;
Example03ScrollView scrollView = null;
void Start()
{

View File

@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example03ScrollView : FancyScrollView<Example03CellDto, Example03ScrollViewContext>
{
[SerializeField]
ScrollPositionController scrollPositionController;
ScrollPositionController scrollPositionController = null;
void Awake()
{

View File

@ -6,13 +6,13 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example03ScrollViewCell : FancyScrollViewCell<Example03CellDto, Example03ScrollViewContext>
{
[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");

View File

@ -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()
{

View File

@ -7,7 +7,7 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example04ScrollView : FancyScrollView<Example04CellDto, Example04ScrollViewContext>
{
[SerializeField]
ScrollPositionController scrollPositionController;
ScrollPositionController scrollPositionController = null;
Action<int> onSelectedIndexChanged;

View File

@ -6,13 +6,13 @@ namespace UnityEngine.UI.Extensions.Examples
public class Example04ScrollViewCell : FancyScrollViewCell<Example04CellDto, Example04ScrollViewContext>
{
[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");

View File

@ -298,9 +298,13 @@ namespace UnityEngine.UI.Extensions
anchorMin[0] = anchorMax[0] = (NormalizedValueX);
anchorMin[1] = anchorMax[1] = (NormalizedValueY);
if (Application.isPlaying)
{
m_HandleRect.anchorMin = anchorMin;
m_HandleRect.anchorMax = anchorMax;
}
}
}
// Update the slider's position based on the mouse.

View File

@ -33,7 +33,7 @@ namespace UnityEngine.UI.Extensions.ColorPicker
List<GameObject> rgbSliders = new List<GameObject>();
[SerializeField]
GameObject alphaSlider;
GameObject alphaSlider = null;
public void SetHSVSlidersOn(bool value)
{

View File

@ -372,7 +372,7 @@ namespace UnityEngine.UI.Extensions
Initialize();
}
void OnDestroy()
protected override void OnDestroy()
{
currentMaterial = null;
currentTexture = null;

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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<Vector3> 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<Vector3> 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
/// <summary>
/// Returns if the SnapScroll is moving
/// </summary>
public bool moving
public bool Moving
{
get
{
return sliding || lerping;
return Sliding || Lerping;
}
}
/// <summary>
/// Returns if the SnapScroll is moving because of a touch
/// </summary>
public bool sliding
public bool Sliding
{
get
{
@ -142,7 +140,7 @@ namespace UnityEngine.UI.Extensions
/// <summary>
/// Returns if the SnapScroll is moving programmatically
/// </summary>
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
/// </summary>
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
/// </summary>
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
/// <param name="info">All of the info about how you want it to move</param>
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

View File

@ -8,15 +8,15 @@ namespace UnityEngine.UI.Extensions
public abstract class FancyScrollView<TData, TContext> : 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<FancyScrollViewCell<TData, TContext>> cells = new List<FancyScrollViewCell<TData, TContext>>();
float currentPosition;

View File

@ -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]

View File

@ -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

View File

@ -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);