forked from setchi/FancyScrollView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
112 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Assets/FancyScrollView/Sources/Runtime/GridView/FancyGridViewCell.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* FancyScrollView (https://github.com/setchi/FancyScrollView) | ||
* Copyright (c) 2019 setchi | ||
* Licensed under MIT (https://github.com/setchi/FancyScrollView/blob/master/LICENSE) | ||
*/ | ||
|
||
using UnityEngine; | ||
|
||
namespace FancyScrollView | ||
{ | ||
/// <summary> | ||
/// <see cref="FancyGridView{TItemData, TContext}"/> のセルを実装するための抽象基底クラス. | ||
/// </summary> | ||
/// <typeparam name="TItemData">アイテムのデータ型.</typeparam> | ||
/// <typeparam name="TContext"><see cref="FancyCell{TItemData, TContext}.Context"/> の型.</typeparam> | ||
public abstract class FancyGridViewCell<TItemData, TContext> : FancyCell<TItemData, TContext> | ||
where TContext : class, IFancyGridViewContext, new() | ||
{ | ||
/// <inheritdoc/> | ||
public override void UpdatePosition(float position) | ||
{ | ||
var cellSize = Context.GetCellSize(); | ||
var spacing = Context.GetColumnSpacing(); | ||
var columnCount = Context.GetColumnCount(); | ||
|
||
var count = Index % columnCount; | ||
var p = (cellSize + spacing) * (count - (columnCount - 1) * 0.5f); | ||
|
||
transform.localPosition = Context.ScrollDirection == ScrollDirection.Horizontal | ||
? new Vector2(transform.localPosition.x, p) | ||
: new Vector2(p, transform.localPosition.y); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="FancyGridView{TItemData}"/> のセルを実装するための抽象基底クラス. | ||
/// </summary> | ||
/// <typeparam name="TItemData">アイテムのデータ型.</typeparam> | ||
/// <seealso cref="FancyGridViewCell{TItemData, TContext}"/> | ||
public abstract class FancyGridViewCell<TItemData> : FancyGridViewCell<TItemData, FancyGridViewContext> | ||
{ | ||
/// <inheritdoc/> | ||
public sealed override void SetContext(FancyGridViewContext context) => base.SetContext(context); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/FancyScrollView/Sources/Runtime/GridView/FancyGridViewCell.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters