public void UpdateData(List <Example03CellDto> data)
 {
     cellData = data;
     scrollPositionController.SetDataCount(cellData.Count);
     RefreshCells();
     UpdateContents();
 }
Exemple #2
0
        public void UpdateData(List <Example04CellDto> data, Example04ScrollViewContext context)
        {
            context.OnPressedCell = OnPressedCell;
            SetContext(context);

            cellData = data;
            scrollPositionController.SetDataCount(cellData.Count);
            UpdateContents();
        }
        public void OnInspectorGUI(UnityEngine.Object target, SerializedObject serializedObject)
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(viewport);
            EditorGUILayout.PropertyField(directionOfRecognize);
            EditorGUILayout.PropertyField(movementType);
            EditorGUILayout.PropertyField(scrollSensitivity);
            EditorGUILayout.PropertyField(inertia);
            DrawInertiaRelatedValues();

            EditorGUILayout.BeginHorizontal();
            int newvalue = EditorGUILayout.IntField("dataCount", dataCount.intValue);

            if (newvalue != dataCount.intValue)
            {
                dataCount.intValue = newvalue;
            }

            if (Application.isPlaying && GUILayout.Button("Sure"))
            {
                BaseFancyScrollView      view       = target as BaseFancyScrollView;
                ScrollPositionController controller = view.controller as ScrollPositionController;

                controller.SetDataCount(newvalue);

                if (view != null)
                {
                    if (field == null)
                    {
                        field = view.GetType().GetField("cellData", BindingFlags.Instance | BindingFlags.NonPublic);
                        list  = (IList)field.GetValue(view);
                    }
                    int datacnt = controller.GetDataCount();
                    if (datacnt < list.Count)
                    {
                        for (int i = list.Count - 1; i >= datacnt; --i)
                        {
                            list.RemoveAt(i);
                        }
                    }
                    else
                    {
                        Type ListElementType = list.GetType().GetGenericArguments()[0];
                        for (int i = list.Count; i < datacnt; ++i)
                        {
                            list.Add(Activator.CreateInstance(ListElementType));
                        }
                    }

                    view.RefreshCells();
                }
            }

            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Exemple #4
0
 public void UpdateData(IList <Example02CellData> cellData)
 {
     UpdateContents(cellData);
     scrollPositionController.SetDataCount(cellData.Count);
 }