Skip to content

Commit

Permalink
Merge pull request #8 from Haruma-K/feature/fix_interfaces
Browse files Browse the repository at this point in the history
Feature/fix interfaces
  • Loading branch information
Haruma-K authored Apr 29, 2023
2 parents bd7859b + 970349d commit a3c112b
Show file tree
Hide file tree
Showing 8 changed files with 637 additions and 50 deletions.
569 changes: 539 additions & 30 deletions Assets/Demo/Scenes/CarouselDemo.unity

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions Assets/Demo/Scripts/Demo.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace Demo.Scripts
{
public class Demo : MonoBehaviour
{
[SerializeField] private DemoCarouselView _carouselView;
[SerializeField] [Range(1, 3)] private int _bannerCount = 3;
[SerializeField] private Button _setupButton;
[SerializeField] private Button _cleanupButton;

private bool _isSetup;

private void Start()
{
_setupButton.onClick.AddListener(Setup);
_cleanupButton.onClick.AddListener(Cleanup);

Setup();
}

private void Setup()
{
if (_isSetup)
return;

var items = Enumerable.Range(0, _bannerCount)
.Select(i =>
{
Expand All @@ -19,6 +35,16 @@ private void Start()
})
.ToArray();
_carouselView.Setup(items);
_isSetup = true;
}

private void Cleanup()
{
if (!_isSetup)
return;

_carouselView.Cleanup();
_isSetup = false;
}
}
}
19 changes: 17 additions & 2 deletions Assets/FancyCarouselView/Runtime/Scripts/CarouselView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using EasingCore;
using FancyScrollView;
using UnityEditor;
Expand Down Expand Up @@ -180,16 +181,30 @@ void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)

public ScrollDirection ScrollDirection => _scroller.ScrollDirection;

public void Setup(IList<TData> dataList)
void ICarouselView<TData, TCell>.Setup(IList<TData> dataList)
{
Setup((IReadOnlyList<TData>)dataList);
}

public void Setup(IReadOnlyList<TData> dataList)
{
DataCount = dataList.Count;
UpdateContents(dataList);

// FancyScrollView only accepts IList, so if it can be converted to IList, convert it, and if it cannot be converted, create a new List.
var list = dataList as IList<TData> ?? dataList.ToList();

UpdateContents(list);
_scroller.SetTotalCount(DataCount);
DataChanged?.Invoke();
if (_progressView != null)
_progressView.Setup(DataCount);
}

public void Cleanup()
{
Setup(Array.Empty<TData>());
}

public void ScrollToBefore(float duration, Ease easeType, Action onComplete = null)
{
var position = ActiveCellPosition - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public override void Setup(int elementCount)
throw new InvalidOperationException(
$"{nameof(DotCarouselProgressView)} requires {nameof(HorizontalLayoutGroup)} or {nameof(VerticalLayoutGroup)}. Make sure it is attached.");


// Remove all instances if exists
foreach (var instance in _progressElementInstances)
Destroy(instance.gameObject);
_progressElementInstances.Clear();

_progressElementInstances = new List<DotCarouselProgressElement>(elementCount);
for (var i = 0; i < elementCount; i++)
{
Expand Down
14 changes: 7 additions & 7 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"dependencies": {
"com.unity.collab-proxy": "1.14.1",
"com.unity.ide.rider": "1.2.1",
"com.unity.ide.visualstudio": "2.0.11",
"com.unity.ide.vscode": "1.2.4",
"com.unity.test-framework": "1.1.29",
"com.unity.textmeshpro": "2.1.4",
"com.unity.timeline": "1.2.18",
"com.unity.collab-proxy": "1.17.2",
"com.unity.ide.rider": "3.0.15",
"com.unity.ide.visualstudio": "2.0.16",
"com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.31",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.4.8",
"com.unity.ugui": "1.0.0",
"jp.setchi.fancyscrollview": "https://github.com/setchi/FancyScrollView.git#upm",
"com.unity.modules.ai": "1.0.0",
Expand Down
41 changes: 32 additions & 9 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"dependencies": {
"com.unity.collab-proxy": {
"version": "1.14.1",
"version": "1.17.2",
"depth": 0,
"source": "registry",
"dependencies": {},
"dependencies": {
"com.unity.services.core": "1.0.1"
},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
Expand All @@ -15,16 +17,16 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "1.2.1",
"version": "3.0.15",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
"com.unity.ext.nunit": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.11",
"version": "2.0.16",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -33,14 +35,23 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.4",
"version": "1.2.5",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.services.core": {
"version": "1.0.1",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.29",
"version": "1.1.31",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -51,7 +62,7 @@
"url": "https://packages.unity.com"
},
"com.unity.textmeshpro": {
"version": "2.1.4",
"version": "3.0.6",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -60,7 +71,7 @@
"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.2.18",
"version": "1.4.8",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down Expand Up @@ -220,6 +231,18 @@
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.uielementsnative": "1.0.0"
}
},
"com.unity.modules.uielementsnative": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.33f1
m_EditorVersionWithRevision: 2019.4.33f1 (c9b2b02eeeef)
m_EditorVersion: 2020.3.40f1
m_EditorVersionWithRevision: 2020.3.40f1 (ba48d4efcef1)
8 changes: 8 additions & 0 deletions ProjectSettings/VersionControlSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!890905787 &1
VersionControlSettings:
m_ObjectHideFlags: 0
m_Mode: Visible Meta Files
m_CollabEditorSettings:
inProgressEnabled: 1

0 comments on commit a3c112b

Please sign in to comment.