setchi/FancyScrollView

NullReferenceException: Object reference not set to an instance of an object

gegagome opened this issue · 1 comments

Hi there

Not sure if it is my own implementation but it looks like there is a problem with your suggested simple example.

This is the error:
NullReferenceException: Object reference not set to an instance of an object
FancyScrollView.FancyScrollView2[TData,TContext].CreateCell () (at Assets/FancyScrollView/Scripts/FancyScrollView.cs:50) FancyScrollView.FancyScrollView2[TData,TContext].UpdatePosition (Single position) (at Assets/FancyScrollView/Scripts/FancyScrollView.cs:166)
FancyScrollView.FancyScrollView`2[TData,TContext].LateUpdate () (at Assets/FancyScrollView/Scripts/FancyScrollView.cs:90)

My scroll view cell looks like this:
`using UnityEngine;
using UnityEngine.UI;
using FancyScrollView;

public class MYOM_ScrollViewCell : FancyScrollViewCell<MYOM_CellData>
{
[SerializeField]
Text message;

public override void UpdateContent(MYOM_CellData itemData)
{
    message.text = itemData._message;
}

public override void UpdatePosition(float position)
{
    // position is a value between 0.0 and 1.0
    // You can control the appearance of the cell freely based on position
}

}`

so it looks like it is having a type mismatch in line 48 of FancyScrollView.cs var cell = cellObject.GetComponent<FancyScrollViewCell<TData, TContext>>();
with the following line 50 var cellRectTransform = cell.transform as RectTransform;

In Unity this problem clones non-stop 'Cells' and not inside a parent object.

Any ideas?

Thanks

Nevermind.

I had not chosen a Text element in the (duplicated) cell element.