├── .idea
├── .name
├── contentModel.xml
├── vcs.xml
├── modules.xml
├── riderModule.iml
└── workspace.xml
├── ProjectSettings
├── ProjectVersion.txt
├── TagManager.asset
├── TimeManager.asset
├── AudioManager.asset
├── InputManager.asset
├── NavMeshAreas.asset
├── DynamicsManager.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── NetworkManager.asset
├── ProjectSettings.asset
├── QualitySettings.asset
├── Physics2DSettings.asset
├── ClusterInputManager.asset
├── EditorBuildSettings.asset
└── UnityConnectSettings.asset
├── UnityTableView.gif
├── Assets
├── Scenes
│ ├── Example Scene.unity
│ └── Example Scene.unity.meta
├── Resources
│ ├── ExampleTableViewCell.prefab
│ └── ExampleTableViewCell.prefab.meta
├── Example.meta
├── Scenes.meta
├── Scripts.meta
├── Resources.meta
├── Scripts
│ ├── Extensions.meta
│ ├── TableView.meta
│ ├── TableView
│ │ ├── Core.meta
│ │ ├── Core
│ │ │ ├── Sizes.meta
│ │ │ ├── Content.meta
│ │ │ ├── Events.meta
│ │ │ ├── Layout.meta
│ │ │ ├── Prefab.meta
│ │ │ ├── Reusable.meta
│ │ │ ├── Scroll.meta
│ │ │ ├── Visible.meta
│ │ │ ├── PlaceHolder.meta
│ │ │ ├── Events
│ │ │ │ ├── TableViewCellDidSelectEvent.cs
│ │ │ │ ├── TableViewCellDidHighlightEvent.cs
│ │ │ │ ├── TableViewCellDidSelectEvent.cs.meta
│ │ │ │ └── TableViewCellDidHighlightEvent.cs.meta
│ │ │ ├── TableView.cs.meta
│ │ │ ├── Sizes
│ │ │ │ ├── CellSizes.cs.meta
│ │ │ │ └── CellSizes.cs
│ │ │ ├── TableViewCell.cs.meta
│ │ │ ├── Prefab
│ │ │ │ ├── PrefabCells.cs.meta
│ │ │ │ └── PrefabCells.cs
│ │ │ ├── Visible
│ │ │ │ ├── VisibleCells.cs.meta
│ │ │ │ └── VisibleCells.cs
│ │ │ ├── Content
│ │ │ │ ├── TableViewContent.cs.meta
│ │ │ │ └── TableViewContent.cs
│ │ │ ├── Layout
│ │ │ │ ├── TableViewLayout.cs.meta
│ │ │ │ └── TableViewLayout.cs
│ │ │ ├── Reusable
│ │ │ │ ├── ReusableCells.cs.meta
│ │ │ │ ├── ReusableContainer.cs.meta
│ │ │ │ ├── ReusableContainer.cs
│ │ │ │ └── ReusableCells.cs
│ │ │ ├── Scroll
│ │ │ │ ├── TableViewScroll.cs.meta
│ │ │ │ └── TableViewScroll.cs
│ │ │ ├── PlaceHolder
│ │ │ │ ├── TableViewPlaceHolders.cs.meta
│ │ │ │ └── TableViewPlaceHolders.cs
│ │ │ ├── TableViewCell.cs
│ │ │ └── TableView.cs
│ │ ├── DataSource.meta
│ │ ├── Delegate.meta
│ │ ├── Delegate
│ │ │ ├── ITableViewDelegate.cs
│ │ │ └── ITableViewDelegate.cs.meta
│ │ ├── ITableView.cs.meta
│ │ ├── DataSource
│ │ │ ├── ITableViewDataSource.cs.meta
│ │ │ └── ITableViewDataSource.cs
│ │ └── ITableView.cs
│ └── Extensions
│ │ ├── RangeExtension.cs.meta
│ │ └── RangeExtension.cs
└── Example
│ ├── ExampleTableViewCell.cs.meta
│ ├── ExampleViewController.cs.meta
│ ├── ExampleTableViewCell.cs
│ └── ExampleViewController.cs
├── .gitignore
├── README.md
└── LICENSE
/.idea/.name:
--------------------------------------------------------------------------------
1 | TableView
--------------------------------------------------------------------------------
/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 5.6.1f1
2 |
--------------------------------------------------------------------------------
/UnityTableView.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/UnityTableView.gif
--------------------------------------------------------------------------------
/Assets/Scenes/Example Scene.unity:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/Assets/Scenes/Example Scene.unity
--------------------------------------------------------------------------------
/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/TagManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/TimeManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/AudioManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/InputManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/NavMeshAreas.asset
--------------------------------------------------------------------------------
/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/DynamicsManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/EditorSettings.asset
--------------------------------------------------------------------------------
/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/GraphicsSettings.asset
--------------------------------------------------------------------------------
/ProjectSettings/NetworkManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/NetworkManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/ProjectSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/ProjectSettings.asset
--------------------------------------------------------------------------------
/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/QualitySettings.asset
--------------------------------------------------------------------------------
/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/Physics2DSettings.asset
--------------------------------------------------------------------------------
/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/ClusterInputManager.asset
--------------------------------------------------------------------------------
/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/EditorBuildSettings.asset
--------------------------------------------------------------------------------
/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/ProjectSettings/UnityConnectSettings.asset
--------------------------------------------------------------------------------
/Assets/Resources/ExampleTableViewCell.prefab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilianerhan/UnityTableView/HEAD/Assets/Resources/ExampleTableViewCell.prefab
--------------------------------------------------------------------------------
/.idea/contentModel.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Assets/Scenes/Example Scene.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 70b4f0fa0e1ca4d9e96d043c26c13b66
3 | timeCreated: 1495184975
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Example.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9ff20cfa72da4484b9c47e5bb72244a0
3 | folderAsset: yes
4 | timeCreated: 1495185095
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c45fe8e01b1f44d08c9d066475d653f
3 | folderAsset: yes
4 | timeCreated: 1495184944
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 549c60349c05449ba95f553062d9c5d1
3 | folderAsset: yes
4 | timeCreated: 1495184829
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Resources.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d96785801b9184f89a072e76c7259f43
3 | folderAsset: yes
4 | timeCreated: 1495445425
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/Extensions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a81103611ff8f41e4ba25e3b0f7b1db9
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eb084048a3a514307a2e3d65d0050e15
3 | folderAsset: yes
4 | timeCreated: 1495185095
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fa3151cd8ee674da9b9774b94e7b3816
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Sizes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: de9d3e404d3f2485aa79d22388c104e3
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/DataSource.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 17bde9fa6fec84784965a004f0bc5e36
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Delegate.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c6a826e994e8343e6bf4c83402aac6c6
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Content.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eca8650f94ce149be8eba48e718e7ffa
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Events.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bb92e1d1a8fde4a3b92a7c0a501a8d25
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Layout.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 680bfeb09d163472a8405066eed7c6f3
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f78fa6f7a045649ba8001c6beeaa2c1a
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Reusable.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45406aebcf49d4a9db4bb90782893521
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Scroll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7f36ff0c1f1e0468ca0ece2435d61640
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Visible.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 297a74a14d39b4c26b98ad152d67c7ee
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/PlaceHolder.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cf3a283421058457ebe37247e32983b4
3 | folderAsset: yes
4 | timeCreated: 1495445124
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Events/TableViewCellDidSelectEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine.Events;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | [Serializable]
7 | public class TableViewCellDidSelectEvent : UnityEvent
8 | {
9 |
10 | }
11 | }
--------------------------------------------------------------------------------
/Assets/Resources/ExampleTableViewCell.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d2063cb269a3740648fe439f9b57e8b1
3 | timeCreated: 1495454237
4 | licenseType: Free
5 | NativeFormatImporter:
6 | mainObjectFileID: 100100000
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Events/TableViewCellDidHighlightEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine.Events;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | [Serializable]
7 | public class TableViewCellDidHighlightEvent : UnityEvent
8 | {
9 |
10 | }
11 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Delegate/ITableViewDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Assets.Scripts.TableView
2 | {
3 | public interface ITableViewDelegate
4 | {
5 | void TableViewDidHighlightCellForRow(TableView tableView, int row);
6 | void TableViewDidSelectCellForRow(TableView tableView, int row);
7 | }
8 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Assets/Example/ExampleTableViewCell.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 01a271cd311774680896409019bca59f
3 | timeCreated: 1495446240
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Example/ExampleViewController.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a8ce0c061cdcf45e288d59e2dc094e40
3 | timeCreated: 1495185095
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/ITableView.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f65be11bff3aa41909044647bc952bd0
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/Extensions/RangeExtension.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aeba2d0470f52415daa2d671f0fda6f2
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/TableView.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 496e36d6437ec4b408a15be997ff2f37
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Sizes/CellSizes.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 12a8c7e5bdde248a596022b2bd3b1b48
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/TableViewCell.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d5c540ae7321a4609a87407ad8c2e985
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Prefab/PrefabCells.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7b1cd6c1427eb457697dbb9d426afca1
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Visible/VisibleCells.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7d63d369de04d43e19fab5afb2daa09a
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Content/TableViewContent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0b8204936df784f5ba3eecc1b3f5f4a9
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Layout/TableViewLayout.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 19bec35bbfe694d98ac2ce1dc70981ee
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Reusable/ReusableCells.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e6fa31ee72e0a40afa51f131589d5838
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Reusable/ReusableContainer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 55b07c478fce54d4282f0f2dae9eff49
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Scroll/TableViewScroll.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c8e333c8a98b54eeda1ffda82126a4c0
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/DataSource/ITableViewDataSource.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a966440e2bc2445178aee9478909df47
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Delegate/ITableViewDelegate.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f7f780268283345aead6191c0a10da46
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/DataSource/ITableViewDataSource.cs:
--------------------------------------------------------------------------------
1 | namespace Assets.Scripts.TableView
2 | {
3 | public interface ITableViewDataSource
4 | {
5 | int NumberOfRowsInTableView(TableView tableView);
6 | float SizeForRowInTableView(TableView tableView, int row);
7 | TableViewCell CellForRowInTableView(TableView tableView, int row);
8 | }
9 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Events/TableViewCellDidSelectEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 661f6956512e545619b97a8c82ac32c2
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/PlaceHolder/TableViewPlaceHolders.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 65f447fa134f3440791614cb787c6bb4
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Events/TableViewCellDidHighlightEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6685ec4b91118417ebc1530ba3caead3
3 | timeCreated: 1495445125
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /[Ll]ibrary/
2 | /[Tt]emp/
3 | /[Oo]bj/
4 | /[Bb]uild/
5 | /[Bb]uilds/
6 | /Assets/AssetStoreTools*
7 |
8 | # Visual Studio 2015 cache directory
9 | /.vs/
10 |
11 | # Autogenerated VS/MD/Consulo solution and project files
12 | ExportedObj/
13 | .consulo/
14 | *.csproj
15 | *.unityproj
16 | *.sln
17 | *.suo
18 | *.tmp
19 | *.user
20 | *.userprefs
21 | *.pidb
22 | *.booproj
23 | *.svd
24 | *.pdb
25 |
26 | # Unity3D generated meta files
27 | *.pidb.meta
28 |
29 | # Unity3D Generated File On Crash Reports
30 | sysinfo.txt
31 |
32 | # Builds
33 | *.apk
34 | *.unitypackage
35 |
--------------------------------------------------------------------------------
/.idea/riderModule.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UnityTableView
2 |
3 | TableView is a plugin for Unity 5.6 that implements a Table with an API inspired by Apple's [UITableView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/index.html)
4 |
5 |
6 |
7 |
8 |
9 | ### Features ###
10 |
11 | * Reusable cells
12 | * Vertical / Horizontal
13 | * No external dependencies
14 | * Can handle tables with large amounts of rows
15 | * Native iOS / Mac developers will feel at home
16 |
--------------------------------------------------------------------------------
/Assets/Scripts/Extensions/RangeExtension.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine.SocialPlatforms;
2 |
3 | namespace Assets.Scripts
4 | {
5 | public static class RangeExtension
6 | {
7 | public static int Last(this Range range)
8 | {
9 | if (range.count == 0)
10 | {
11 | throw new System.InvalidOperationException("Range is invalid");
12 | }
13 | return (range.from + range.count - 1);
14 | }
15 |
16 | public static bool Contains(this Range range, int num)
17 | {
18 | return num >= range.from && num < (range.from + range.count);
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Reusable/ReusableContainer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Assets.Scripts.TableView
4 | {
5 | public class ReusableContainer
6 | {
7 | #region Property
8 |
9 | public readonly RectTransform Container;
10 | private static string reusableContainerIdentifier = "Reusable Cells Container";
11 |
12 | #endregion
13 |
14 | #region Public
15 |
16 | public ReusableContainer(RectTransform transform)
17 | {
18 | Container = new GameObject(reusableContainerIdentifier, typeof(RectTransform)).GetComponent();
19 | Container.SetParent(transform, false);
20 | Container.gameObject.SetActive(false);
21 | }
22 |
23 | #endregion
24 | }
25 | }
--------------------------------------------------------------------------------
/Assets/Example/ExampleTableViewCell.cs:
--------------------------------------------------------------------------------
1 | using Assets.Scripts.TableView;
2 | using UnityEngine.UI;
3 |
4 | namespace Assets.Scripts.Example
5 | {
6 | public class ExampleTableViewCell : TableViewCell
7 | {
8 | public Text text;
9 |
10 | public override string ReuseIdentifier
11 | {
12 | get { return "ExampleTableViewCellReuseIdentifier"; }
13 | }
14 |
15 | public override void SetHighlighted()
16 | {
17 | print("CellSetHighlighted : " + RowNumber);
18 | }
19 |
20 | public override void SetSelected()
21 | {
22 | print("CellSetSelected : " + RowNumber);
23 | }
24 |
25 | public override void Display()
26 | {
27 | text.text = "Row " + RowNumber;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/ITableView.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.SocialPlatforms;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | public interface ITableView
7 | {
8 | ITableViewDataSource DataSource { get; set; }
9 | ITableViewDelegate Delegate { get; set; }
10 |
11 | Range VisibleRange { get; }
12 | float ContentSize { get; }
13 | float Position { get; }
14 |
15 | TableViewCell ReusableCellForRow(string reuseIdentifier, int row);
16 | TableViewCell CellForRow(int row);
17 | float PositionForRow(int row);
18 | void ReloadData();
19 |
20 | void SetPosition(float newPosition);
21 | void SetPosition(float newPosition, float time);
22 |
23 | void RegisterPrefabForCellReuseIdentifier(GameObject prefab, string cellReuseIdentifier);
24 | }
25 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Lilian Erhan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Visible/VisibleCells.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine.SocialPlatforms;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | public class VisibleCells
7 | {
8 | #region Property
9 |
10 | public Range Range;
11 | private Dictionary cells;
12 |
13 | public int Count
14 | {
15 | get { return cells.Count; }
16 | }
17 |
18 | #endregion
19 |
20 | #region Public
21 |
22 | public VisibleCells()
23 | {
24 | Range = new Range(0, 0);
25 | cells = new Dictionary();
26 | }
27 |
28 | public TableViewCell GetCellAtIndex(int index)
29 | {
30 | TableViewCell cell = null;
31 | cells.TryGetValue(index, out cell);
32 | return cell;
33 | }
34 |
35 | public void SetCellAtIndex(int index, TableViewCell cell)
36 | {
37 | cells[index] = cell;
38 | }
39 |
40 | public void RemoveCellAtIndex(int index)
41 | {
42 | cells.Remove(index);
43 | }
44 |
45 | #endregion
46 | }
47 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Prefab/PrefabCells.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | public class PrefabCells
7 | {
8 | private Dictionary registeredCells;
9 |
10 | public PrefabCells()
11 | {
12 | registeredCells = new Dictionary();
13 | }
14 |
15 | public void RegisterPrefabForCellReuseIdentifier(GameObject prefab, string cellReuseIdentifier)
16 | {
17 | if (string.IsNullOrEmpty(cellReuseIdentifier)) return;
18 | if (registeredCells.ContainsKey(cellReuseIdentifier)) return;
19 |
20 | registeredCells.Add(cellReuseIdentifier, prefab);
21 | }
22 |
23 | public GameObject PrefabForCellReuseIdentifier(string cellReuseIdentifier)
24 | {
25 | if (string.IsNullOrEmpty(cellReuseIdentifier)) return null;
26 | if (!IsRegisteredCellReuseIdentifier(cellReuseIdentifier)) return null;
27 |
28 | return registeredCells[cellReuseIdentifier];
29 | }
30 |
31 | public bool IsRegisteredCellReuseIdentifier(string cellReuseIdentifier)
32 | {
33 | if (string.IsNullOrEmpty(cellReuseIdentifier)) return false;
34 |
35 | return registeredCells.ContainsKey(cellReuseIdentifier);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Content/TableViewContent.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Assets.Scripts.TableView
4 | {
5 | public class TableViewContent
6 | {
7 | #region Property
8 |
9 | public RectTransform Container { get; private set; }
10 |
11 | private static string containerIdentifier = "Table View Content";
12 |
13 | #endregion
14 |
15 | #region Public
16 |
17 | public TableViewContent(RectTransform transform)
18 | {
19 | Container = new GameObject(containerIdentifier, typeof(RectTransform)).GetComponent();
20 | Container.SetParent(transform, false);
21 | Container.gameObject.SetActive(true);
22 | Container.offsetMin = Vector2.zero;
23 | Container.offsetMax = Vector2.zero;
24 | }
25 |
26 | public void SetLayoutOrientation(TableViewLayoutOrientation layoutOrientation)
27 | {
28 | if (layoutOrientation == TableViewLayoutOrientation.Horizontal)
29 | {
30 | Container.anchorMin = new Vector2(0f, 0f);
31 | Container.anchorMax = new Vector2(0f, 1f);
32 | Container.pivot = new Vector2(0.0f, 0.5f);
33 | }
34 | else
35 | {
36 | Container.anchorMin = new Vector2(0f, 1f);
37 | Container.anchorMax = new Vector2(1f, 1f);
38 | Container.pivot = new Vector2(0.5f, 1.0f);
39 | }
40 | }
41 |
42 | #endregion
43 | }
44 | }
--------------------------------------------------------------------------------
/Assets/Example/ExampleViewController.cs:
--------------------------------------------------------------------------------
1 | using Assets.Scripts.TableView;
2 | using UnityEngine;
3 |
4 | namespace Assets.Scripts.Example
5 | {
6 | public class ExampleViewController : MonoBehaviour, ITableViewDataSource, ITableViewDelegate
7 | {
8 | public TableView.TableView tableView;
9 |
10 | void Start()
11 | {
12 | tableView.Delegate = this;
13 | tableView.DataSource = this;
14 |
15 | GameObject prefab = Resources.Load("ExampleTableViewCell") as GameObject;
16 | tableView.RegisterPrefabForCellReuseIdentifier(prefab, "ExampleTableViewCellReuseIdentifier");
17 | }
18 |
19 | public int NumberOfRowsInTableView(TableView.TableView tableView)
20 | {
21 | return 100;
22 | }
23 |
24 | public float SizeForRowInTableView(TableView.TableView tableView, int row)
25 | {
26 | return Random.Range(50.0f, 200.0f);
27 | }
28 |
29 | public TableViewCell CellForRowInTableView(TableView.TableView tableView, int row)
30 | {
31 | TableViewCell cell = tableView.ReusableCellForRow("ExampleTableViewCellReuseIdentifier", row);
32 | cell.name = "Cell " + row;
33 | return cell;
34 | }
35 |
36 | public void TableViewDidHighlightCellForRow(TableView.TableView tableView, int row)
37 | {
38 | print("TableViewDidHighlightCellForRow : " + row);
39 | }
40 |
41 | public void TableViewDidSelectCellForRow(TableView.TableView tableView, int row)
42 | {
43 | print("TableViewDidSelectCellForRow : " + row);
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/TableViewCell.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.EventSystems;
3 | using UnityEngine.UI;
4 |
5 | namespace Assets.Scripts.TableView
6 | {
7 | public abstract class TableViewCell : MonoBehaviour, ISelectHandler, ISubmitHandler, IPointerClickHandler
8 | {
9 | #region Property
10 |
11 | public int RowNumber
12 | {
13 | get { return rowNumber; }
14 | }
15 |
16 | public abstract string ReuseIdentifier { get; }
17 |
18 | public TableViewCellDidSelectEvent DidSelectEvent;
19 | public TableViewCellDidHighlightEvent DidHighlightEvent;
20 |
21 | private int rowNumber;
22 |
23 | #endregion
24 |
25 | #region Lifecycle
26 |
27 | void Awake()
28 | {
29 | this.gameObject.AddComponent();
30 | }
31 |
32 | #endregion
33 |
34 | #region Public
35 |
36 | public abstract void SetHighlighted();
37 | public abstract void SetSelected();
38 | public abstract void Display();
39 |
40 | public void SetRowNumber(int number)
41 | {
42 | rowNumber = number;
43 |
44 | Display();
45 | }
46 |
47 | public void OnSelect(BaseEventData eventData)
48 | {
49 | SetHighlighted();
50 |
51 | if (DidHighlightEvent == null) return;
52 |
53 | DidHighlightEvent.Invoke(rowNumber);
54 | }
55 |
56 | public void OnSubmit(BaseEventData eventData)
57 | {
58 | SetSelected();
59 |
60 | if (DidSelectEvent == null) return;
61 |
62 | DidSelectEvent.Invoke(rowNumber);
63 | }
64 |
65 | public void OnPointerClick(PointerEventData eventData)
66 | {
67 | SetSelected();
68 |
69 | if (DidSelectEvent == null) return;
70 |
71 | DidSelectEvent.Invoke(rowNumber);
72 | }
73 |
74 | #endregion
75 | }
76 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Reusable/ReusableCells.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace Assets.Scripts.TableView
6 | {
7 | public class ReusableCells
8 | {
9 | #region Property
10 |
11 | private ReusableContainer reusableContainer;
12 | private readonly Dictionary> reusableCells;
13 |
14 | #endregion
15 |
16 | #region Public
17 |
18 | public ReusableCells()
19 | {
20 | reusableCells = new Dictionary>();
21 | }
22 |
23 | public void AddToParentTransform(RectTransform transform)
24 | {
25 | reusableContainer = new ReusableContainer(transform);
26 | }
27 |
28 | public void AddReusableCell(TableViewCell cell)
29 | {
30 | if (!IsValidContainer()) return;
31 | if (string.IsNullOrEmpty(cell.ReuseIdentifier)) return;
32 |
33 | if (!reusableCells.ContainsKey(cell.ReuseIdentifier))
34 | {
35 | reusableCells.Add(cell.ReuseIdentifier, new LinkedList());
36 | }
37 |
38 | reusableCells[cell.ReuseIdentifier].AddLast(cell);
39 | cell.transform.SetParent(reusableContainer.Container, false);
40 | }
41 |
42 | public TableViewCell GetReusableCell(string reuseIdentifier)
43 | {
44 | LinkedList reusableCellsList;
45 |
46 | if (!reusableCells.TryGetValue(reuseIdentifier, out reusableCellsList)) return null;
47 | if (reusableCellsList.Count == 0) return null;
48 |
49 | TableViewCell reusableCell = reusableCellsList.First.Value;
50 | reusableCellsList.RemoveFirst();
51 |
52 | return reusableCell;
53 | }
54 |
55 | #endregion
56 |
57 | #region Private
58 |
59 | private bool IsValidContainer()
60 | {
61 | if (reusableContainer == null)
62 | {
63 | throw new Exception("Reusable Container can not be null !!!");
64 | }
65 |
66 | return true;
67 | }
68 |
69 | #endregion
70 | }
71 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/PlaceHolder/TableViewPlaceHolders.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | public class TableViewPlaceHolders
7 | {
8 | #region Property
9 |
10 | private LayoutElement startPlaceHolder;
11 | private LayoutElement endPlaceholder;
12 |
13 | private static string startPlaceHolderIdentifier = "Start Place Holder";
14 | private static string endPlaceHolderIdentifier = "End Place Holder";
15 | private TableViewLayoutOrientation layoutOrientation;
16 |
17 | #endregion
18 |
19 | #region Public
20 |
21 | public TableViewPlaceHolders(Transform transform)
22 | {
23 | CreateStartPlaceHolderWithTransform(transform);
24 | CreateEndPlaceHolderWithTransform(transform);
25 | }
26 |
27 | public void SetLayoutOrientation(TableViewLayoutOrientation layoutOrientation)
28 | {
29 | this.layoutOrientation = layoutOrientation;
30 | }
31 |
32 | public void UpdatePlaceHoldersWithSize(float startSize, float endSize)
33 | {
34 | if (layoutOrientation == TableViewLayoutOrientation.Horizontal)
35 | {
36 | startPlaceHolder.preferredWidth = startSize;
37 | endPlaceholder.preferredWidth = endSize;
38 | }
39 | else
40 | {
41 | startPlaceHolder.preferredHeight = startSize;
42 | endPlaceholder.preferredHeight = endSize;
43 | }
44 |
45 | startPlaceHolder.gameObject.SetActive(startSize > 0);
46 | endPlaceholder.gameObject.SetActive(endSize > 0);
47 | }
48 |
49 | #endregion
50 |
51 | #region Private
52 |
53 | private void CreateStartPlaceHolderWithTransform(Transform transform)
54 | {
55 | startPlaceHolder = CreatePlaceHolderWithIdentifier(startPlaceHolderIdentifier);
56 | startPlaceHolder.transform.SetParent(transform, false);
57 | startPlaceHolder.gameObject.SetActive(false);
58 | }
59 |
60 | private void CreateEndPlaceHolderWithTransform(Transform transform)
61 | {
62 | endPlaceholder = CreatePlaceHolderWithIdentifier(endPlaceHolderIdentifier);
63 | endPlaceholder.transform.SetParent(transform, false);
64 | endPlaceholder.gameObject.SetActive(false);
65 | }
66 |
67 | private LayoutElement CreatePlaceHolderWithIdentifier(string name)
68 | {
69 | GameObject gameObject = new GameObject(name, typeof(RectTransform), typeof(LayoutElement));
70 | return gameObject.GetComponent();
71 | }
72 |
73 | #endregion
74 | }
75 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Sizes/CellSizes.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine.SocialPlatforms;
2 |
3 | namespace Assets.Scripts.TableView
4 | {
5 | public class CellSizes
6 | {
7 | #region Property
8 |
9 | private float[] rowSize;
10 | private float[] cumulativeRowSize;
11 | public int CumulativeIndex = -1;
12 |
13 | public int RowsCount
14 | {
15 | get { return rowSize.Length; }
16 | }
17 |
18 | public int CumulativeRowsCount
19 | {
20 | get { return cumulativeRowSize.Length; }
21 | }
22 |
23 | #endregion
24 |
25 | #region Public
26 |
27 | public void SetRowsCount(int count)
28 | {
29 | CumulativeIndex = -1;
30 | rowSize = new float[count];
31 | cumulativeRowSize = new float[count];
32 | }
33 |
34 | public void SetSizeForRow(float size, int row)
35 | {
36 | if (size <= 0) return;
37 | if (row >= RowsCount) return;
38 |
39 | rowSize[row] = size;
40 | }
41 |
42 | public float SizeForRow(int row)
43 | {
44 | return rowSize[row];
45 | }
46 |
47 | public float SumWithRange(Range range)
48 | {
49 | float sum = 0;
50 |
51 | for (int i = range.from; i < range.count; i++)
52 | {
53 | sum += SizeForRow(i);
54 | }
55 |
56 | return sum;
57 | }
58 |
59 | public float GetCumulativeRowSize(int row)
60 | {
61 | while (CumulativeIndex < row)
62 | {
63 | CumulativeIndex++;
64 | cumulativeRowSize[CumulativeIndex] = rowSize[CumulativeIndex];
65 |
66 | if (CumulativeIndex > 0)
67 | {
68 | cumulativeRowSize[CumulativeIndex] += cumulativeRowSize[CumulativeIndex - 1];
69 | }
70 | }
71 | return cumulativeRowSize[row];
72 | }
73 |
74 | public int FindIndexOfRowAtPosition(float position)
75 | {
76 | return FindIndexOfRowAtPosition(position, 0, cumulativeRowSize.Length - 1);
77 | }
78 |
79 | public int FindIndexOfRowAtPosition(float position, int startIndex, int endIndex)
80 | {
81 | if (startIndex >= endIndex) return startIndex;
82 |
83 | int midIndex = (startIndex + endIndex) / 2;
84 |
85 | if (GetCumulativeRowSize(midIndex) > position)
86 | {
87 | return FindIndexOfRowAtPosition(position, startIndex, midIndex);
88 | }
89 | else
90 | {
91 | return FindIndexOfRowAtPosition(position, midIndex + 1, endIndex);
92 | }
93 | }
94 |
95 | #endregion
96 | }
97 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Layout/TableViewLayout.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | public enum TableViewLayoutOrientation
7 | {
8 | Vertical,
9 | Horizontal
10 | }
11 |
12 | public class TableViewLayout
13 | {
14 | #region Property
15 |
16 | public float Spacing
17 | {
18 | get { return layout.spacing; }
19 | set { layout.spacing = value; }
20 | }
21 |
22 | public RectOffset Padding
23 | {
24 | get { return layout.padding; }
25 | set { layout.padding = value; }
26 | }
27 |
28 | public int StartPadding
29 | {
30 | get
31 | {
32 | if (Orientation == TableViewLayoutOrientation.Horizontal)
33 | {
34 | return layout.padding.left;
35 | }
36 | else
37 | {
38 | return layout.padding.top;
39 | }
40 | }
41 | set
42 | {
43 | if (Orientation == TableViewLayoutOrientation.Horizontal)
44 | {
45 | layout.padding.left = value;
46 | }
47 | else
48 | {
49 | layout.padding.top = value;
50 | }
51 | }
52 | }
53 |
54 | public int EndPadding
55 | {
56 | get
57 | {
58 | if (Orientation == TableViewLayoutOrientation.Horizontal)
59 | {
60 | return layout.padding.right;
61 | }
62 | else
63 | {
64 | return layout.padding.bottom;
65 | }
66 | }
67 | set
68 | {
69 | if (Orientation == TableViewLayoutOrientation.Horizontal)
70 | {
71 | layout.padding.right = value;
72 | }
73 | else
74 | {
75 | layout.padding.bottom = value;
76 | }
77 | }
78 | }
79 |
80 | public TableViewLayoutOrientation Orientation { get; private set; }
81 |
82 | private HorizontalOrVerticalLayoutGroup layout;
83 |
84 | #endregion
85 |
86 | #region Public
87 |
88 | public TableViewLayout(TableViewLayoutOrientation orientation)
89 | {
90 | Orientation = orientation;
91 | }
92 |
93 | public void AddToParent(GameObject gameObject)
94 | {
95 | if (Orientation == TableViewLayoutOrientation.Horizontal)
96 | {
97 | layout = gameObject.AddComponent();
98 | layout.childAlignment = TextAnchor.MiddleLeft;
99 | layout.childForceExpandHeight = true;
100 | layout.childForceExpandWidth = false;
101 | }
102 | else
103 | {
104 | layout = gameObject.AddComponent();
105 | layout.childAlignment = TextAnchor.UpperCenter;
106 | layout.childForceExpandHeight = false;
107 | layout.childForceExpandWidth = true;
108 | }
109 | }
110 |
111 | #endregion
112 | }
113 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/Scroll/TableViewScroll.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | namespace Assets.Scripts.TableView
5 | {
6 | public class TableViewScroll
7 | {
8 | #region Property
9 |
10 | public RectTransform Content
11 | {
12 | get { return scrollRect.content; }
13 | }
14 |
15 | public float Size
16 | {
17 | get
18 | {
19 | if (layoutOrientation == TableViewLayoutOrientation.Horizontal)
20 | {
21 | return Content.rect.width;
22 | }
23 | else
24 | {
25 | return Content.rect.height;
26 | }
27 | }
28 | }
29 |
30 | public float SizeDelta
31 | {
32 | get
33 | {
34 | if (layoutOrientation == TableViewLayoutOrientation.Horizontal)
35 | {
36 | return Content.sizeDelta.y;
37 | }
38 | else
39 | {
40 | return Content.sizeDelta.x;
41 | }
42 | }
43 | set
44 | {
45 | if (layoutOrientation == TableViewLayoutOrientation.Horizontal)
46 | {
47 | Content.sizeDelta = new Vector2(value, Content.sizeDelta.y);
48 | }
49 | else
50 | {
51 | Content.sizeDelta = new Vector2(Content.sizeDelta.x, value);
52 | }
53 | }
54 | }
55 |
56 | public ScrollRect.ScrollRectEvent OnValueChanged
57 | {
58 | get { return scrollRect.onValueChanged; }
59 | }
60 |
61 | public ScrollRect.MovementType MovementType
62 | {
63 | get { return scrollRect.movementType; }
64 | set { scrollRect.movementType = value; }
65 | }
66 |
67 | public float Elasticity
68 | {
69 | get { return scrollRect.elasticity; }
70 | set { scrollRect.elasticity = value; }
71 | }
72 |
73 | public bool Inertia
74 | {
75 | get { return scrollRect.inertia; }
76 | set { scrollRect.inertia = value; }
77 | }
78 |
79 | public float DecelerationRate
80 | {
81 | get { return scrollRect.decelerationRate; }
82 | set { scrollRect.decelerationRate = value; }
83 | }
84 |
85 | public float ScrollSensitivity
86 | {
87 | get { return scrollRect.scrollSensitivity; }
88 | set { scrollRect.scrollSensitivity = value; }
89 | }
90 |
91 | private ScrollRect scrollRect;
92 | private TableViewLayoutOrientation layoutOrientation;
93 |
94 | #endregion
95 |
96 | #region Public
97 |
98 | public TableViewScroll(GameObject gameObject, RectTransform transform)
99 | {
100 | scrollRect = gameObject.AddComponent();
101 | scrollRect.content = transform;
102 | scrollRect.gameObject.SetActive(true);
103 | scrollRect.movementType = MovementType;
104 | scrollRect.elasticity = Elasticity;
105 | scrollRect.inertia = Inertia;
106 | scrollRect.decelerationRate = DecelerationRate;
107 | scrollRect.scrollSensitivity = ScrollSensitivity;
108 | }
109 |
110 | public void SetLayoutOrientation(TableViewLayoutOrientation layoutOrientation)
111 | {
112 | this.layoutOrientation = layoutOrientation;
113 |
114 | if (this.layoutOrientation == TableViewLayoutOrientation.Horizontal)
115 | {
116 | scrollRect.horizontal = true;
117 | scrollRect.vertical = false;
118 | }
119 | else
120 | {
121 | scrollRect.horizontal = false;
122 | scrollRect.vertical = true;
123 | }
124 | }
125 |
126 | public void SetNormalizedPosition(float normalizedPosition)
127 | {
128 | if (layoutOrientation == TableViewLayoutOrientation.Horizontal)
129 | {
130 | scrollRect.horizontalNormalizedPosition = normalizedPosition;
131 | }
132 | else
133 | {
134 | scrollRect.verticalNormalizedPosition = normalizedPosition;
135 | }
136 | }
137 |
138 | #endregion
139 | }
140 | }
--------------------------------------------------------------------------------
/Assets/Scripts/TableView/Core/TableView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using UnityEngine;
4 | using UnityEngine.SocialPlatforms;
5 | using UnityEngine.UI;
6 |
7 | namespace Assets.Scripts.TableView
8 | {
9 | public class TableView : MonoBehaviour, ITableView
10 | {
11 | #region Property
12 |
13 | [SerializeField] private TableViewLayoutOrientation layoutOrientation = TableViewLayoutOrientation.Vertical;
14 | [SerializeField] private float interItemSpacing = 10.0f;
15 | [SerializeField] private RectOffset padding;
16 |
17 | [SerializeField] private bool inertia = true;
18 | [SerializeField] private ScrollRect.MovementType movementType = ScrollRect.MovementType.Elastic;
19 | [SerializeField] private float elasticity = 0.1f;
20 | [SerializeField] private float scrollSensitivity = 1.0f;
21 | [SerializeField] private float decelerationRate = 0.135f;
22 |
23 | [SerializeField] private bool scrollToHighlighted = true;
24 | [SerializeField] private float scrollingSpeed = 0.2f;
25 |
26 | public ITableViewDataSource DataSource
27 | {
28 | get { return dataSource; }
29 | set { dataSource = value; requiresReload = true; }
30 | }
31 |
32 | public ITableViewDelegate Delegate
33 | {
34 | get { return tableViewDelegate; }
35 | set { tableViewDelegate = value; }
36 | }
37 |
38 | public Range VisibleRange
39 | {
40 | get { return visibleCells.Range; }
41 | }
42 |
43 | public float ContentSize
44 | {
45 | get { return tableViewScroll.Size - tableViewSize; }
46 | }
47 |
48 | public float Position
49 | {
50 | get { return position; }
51 | }
52 |
53 | private CellSizes cellSizes;
54 | private PrefabCells prefabCells;
55 | private VisibleCells visibleCells;
56 | private ReusableCells reusableCells;
57 |
58 | private TableViewScroll tableViewScroll;
59 | private TableViewLayout tableViewLayout;
60 | private TableViewContent tableViewContent;
61 | private TableViewPlaceHolders tableViewPlaceHolders;
62 |
63 | private ITableViewDataSource dataSource;
64 | private ITableViewDelegate tableViewDelegate;
65 |
66 | private float position;
67 |
68 | private bool isEmpty;
69 | private bool requiresReload;
70 | private bool requiresRefresh;
71 |
72 | private bool isVertical
73 | {
74 | get { return (tableViewLayout.Orientation == TableViewLayoutOrientation.Vertical); }
75 | }
76 |
77 | private float tableViewSize
78 | {
79 | get
80 | {
81 | Rect rect = (this.transform as RectTransform).rect;
82 | return isVertical ? rect.height : rect.width;
83 | }
84 | }
85 |
86 | #endregion
87 |
88 |
89 | #region Lifecycle
90 |
91 | void Awake()
92 | {
93 | isEmpty = true;
94 |
95 | cellSizes = new CellSizes();
96 | prefabCells = new PrefabCells();
97 | visibleCells = new VisibleCells();
98 |
99 | reusableCells = new ReusableCells();
100 | reusableCells.AddToParentTransform(this.transform as RectTransform);
101 |
102 | tableViewContent = new TableViewContent(this.transform as RectTransform);
103 | tableViewContent.SetLayoutOrientation(layoutOrientation);
104 |
105 | tableViewScroll = new TableViewScroll(this.gameObject, tableViewContent.Container);
106 | tableViewScroll.SetLayoutOrientation(layoutOrientation);
107 | tableViewScroll.Elasticity = elasticity;
108 | tableViewScroll.MovementType = movementType;
109 | tableViewScroll.Inertia = inertia;
110 | tableViewScroll.DecelerationRate = decelerationRate;
111 | tableViewScroll.ScrollSensitivity = scrollSensitivity;
112 |
113 | tableViewPlaceHolders = new TableViewPlaceHolders(tableViewScroll.Content);
114 | tableViewPlaceHolders.SetLayoutOrientation(layoutOrientation);
115 |
116 | tableViewLayout = new TableViewLayout(layoutOrientation);
117 | tableViewLayout.AddToParent(tableViewScroll.Content.gameObject);
118 | tableViewLayout.Spacing = interItemSpacing;
119 | tableViewLayout.Padding = padding;
120 |
121 | this.gameObject.AddComponent();
122 | this.gameObject.AddComponent();
123 | }
124 |
125 | void Update()
126 | {
127 | if (requiresReload)
128 | {
129 | ReloadData();
130 | }
131 | }
132 |
133 | void LateUpdate()
134 | {
135 | if (requiresRefresh)
136 | {
137 | RefreshVisibleCells();
138 | }
139 | }
140 |
141 | void OnEnable()
142 | {
143 | tableViewScroll.OnValueChanged.AddListener(ScrollViewValueChanged);
144 | }
145 |
146 | void OnDisable()
147 | {
148 | tableViewScroll.OnValueChanged.RemoveListener(ScrollViewValueChanged);
149 | }
150 |
151 | #endregion
152 |
153 |
154 | #region Public
155 |
156 | public TableViewCell ReusableCellForRow(string reuseIdentifier, int row)
157 | {
158 | TableViewCell cell = reusableCells.GetReusableCell(reuseIdentifier);
159 |
160 | if (cell == null)
161 | {
162 | cell = CreateCellFromPrefab(reuseIdentifier, row);
163 | }
164 |
165 | return cell;
166 | }
167 |
168 | public TableViewCell CellForRow(int row)
169 | {
170 | return visibleCells.GetCellAtIndex(row);
171 | }
172 |
173 | public float PositionForRow(int row)
174 | {
175 | return cellSizes.GetCumulativeRowSize(row) - cellSizes.SizeForRow(row) + tableViewLayout.StartPadding;
176 | }
177 |
178 | public void ReloadData()
179 | {
180 | int numberOfRows = dataSource.NumberOfRowsInTableView(this);
181 | cellSizes.SetRowsCount(numberOfRows);
182 | isEmpty = (numberOfRows == 0);
183 | RemoveAllCells();
184 |
185 | if (isEmpty) return;
186 |
187 | for (int i = 0; i < numberOfRows; i++)
188 | {
189 | float rowSize = dataSource.SizeForRowInTableView(this, i) + tableViewLayout.Spacing;
190 | cellSizes.SetSizeForRow(rowSize, i);
191 | }
192 |
193 | tableViewScroll.SizeDelta = cellSizes.GetCumulativeRowSize(numberOfRows - 1) + tableViewLayout.EndPadding;
194 |
195 | CreateCells();
196 | requiresReload = false;
197 | }
198 |
199 | public void RegisterPrefabForCellReuseIdentifier(GameObject prefab, string cellReuseIdentifier)
200 | {
201 | prefabCells.RegisterPrefabForCellReuseIdentifier(prefab, cellReuseIdentifier);
202 | }
203 |
204 | public void SetPosition(float newPosition)
205 | {
206 | if (isEmpty) { return; }
207 |
208 | newPosition = Mathf.Clamp(newPosition, 0, PositionForRow(cellSizes.RowsCount - 1));
209 |
210 | if (position != newPosition)
211 | {
212 | position = newPosition;
213 | requiresRefresh = true;
214 | float normalizedPosition = newPosition / ContentSize;
215 | float relativeScroll = 0;
216 |
217 | if (isVertical)
218 | {
219 | relativeScroll = 1 - normalizedPosition;
220 | }
221 | else
222 | {
223 | relativeScroll = normalizedPosition;
224 | }
225 |
226 | tableViewScroll.SetNormalizedPosition(relativeScroll);
227 | }
228 | }
229 |
230 | public void SetPosition(float newPosition, float time)
231 | {
232 | StartCoroutine(AnimateToPosition(newPosition, time));
233 | }
234 |
235 | #endregion
236 |
237 |
238 | #region Private
239 |
240 | private TableViewCell CreateCellFromPrefab(string reuseIdentifier, int row)
241 | {
242 | if (!prefabCells.IsRegisteredCellReuseIdentifier(reuseIdentifier)) return null;
243 |
244 | GameObject cellPrefab = prefabCells.PrefabForCellReuseIdentifier(reuseIdentifier);
245 | TableViewCell cell = Instantiate(cellPrefab).GetComponent();
246 | cell.SetRowNumber(row);
247 |
248 | return ConfigureCellWithRowAtEnd(cell, row, true);
249 | }
250 |
251 | private void ScrollViewValueChanged(Vector2 newScrollValue)
252 | {
253 | float relativeScroll = 0;
254 |
255 | if (isVertical)
256 | {
257 | relativeScroll = 1 - newScrollValue.y;
258 | }
259 | else
260 | {
261 | relativeScroll = newScrollValue.x;
262 | }
263 |
264 | position = relativeScroll * ContentSize;
265 | requiresRefresh = true;
266 | }
267 |
268 | private void CreateCells()
269 | {
270 | RemoveAllCells();
271 | SetInitialVisibleCells();
272 | }
273 |
274 | private void RemoveAllCells()
275 | {
276 | while (visibleCells.Count > 0)
277 | {
278 | RemoveCell(false);
279 | }
280 |
281 | visibleCells.Range = new Range(0, 0);
282 | }
283 |
284 | private Range CurrentVisibleCellsRange()
285 | {
286 | float startPosition = Math.Max(position - tableViewLayout.StartPadding - tableViewSize, 0);
287 | float endPosition = position + (tableViewSize * 2.0f);
288 |
289 | if (endPosition > tableViewScroll.Size)
290 | {
291 | endPosition = tableViewScroll.Size;
292 | }
293 |
294 | int startIndex = cellSizes.FindIndexOfRowAtPosition(startPosition);
295 | int endIndex = cellSizes.FindIndexOfRowAtPosition(endPosition);
296 |
297 | if (endIndex == cellSizes.RowsCount - 1)
298 | {
299 | endIndex = cellSizes.RowsCount;
300 | }
301 |
302 | int cellsCount = endIndex - startIndex;
303 |
304 | return new Range(startIndex, cellsCount);
305 | }
306 |
307 | private void SetInitialVisibleCells()
308 | {
309 | Range currentRange = CurrentVisibleCellsRange();
310 |
311 | for (int i = 0; i < currentRange.count; i++)
312 | {
313 | CreateCell(currentRange.from + i, true);
314 | }
315 |
316 | visibleCells.Range = currentRange;
317 | UpdatePaddingElements();
318 | }
319 |
320 | private void RefreshVisibleCells()
321 | {
322 | requiresRefresh = false;
323 |
324 | if (isEmpty) return;
325 |
326 | Range previousRange = visibleCells.Range;
327 | Range currentRange = CurrentVisibleCellsRange();
328 |
329 | if (currentRange.from > previousRange.Last() || currentRange.Last() < previousRange.from)
330 | {
331 | CreateCells();
332 | return;
333 | }
334 |
335 | RemoveCellsIfNeededWithRanges(previousRange, currentRange);
336 | CreateCellsIfNeededWithRanges(previousRange, currentRange);
337 |
338 | visibleCells.Range = currentRange;
339 |
340 | UpdatePaddingElements();
341 | }
342 |
343 | private void RemoveCellsIfNeededWithRanges(Range previousRange, Range currentRange)
344 | {
345 | for (int i = previousRange.from; i < currentRange.from; i++)
346 | {
347 | RemoveCell(false);
348 | }
349 |
350 | for (int i = currentRange.Last(); i < previousRange.Last(); i++)
351 | {
352 | RemoveCell(true);
353 | }
354 | }
355 |
356 | private void CreateCellsIfNeededWithRanges(Range previousRange, Range currentRange)
357 | {
358 | for (int i = previousRange.from - 1; i >= currentRange.from; i--)
359 | {
360 | CreateCell(i, false);
361 | }
362 |
363 | for (int i = previousRange.Last() + 1; i <= currentRange.Last(); i++)
364 | {
365 | CreateCell(i, true);
366 | }
367 | }
368 |
369 | private void CreateCell(int row, bool atEnd)
370 | {
371 | TableViewCell cell = dataSource.CellForRowInTableView(this, row);
372 | cell = ConfigureCellWithRowAtEnd(cell, row, atEnd);
373 | }
374 |
375 | private TableViewCell ConfigureCellWithRowAtEnd(TableViewCell cell, int row, bool atEnd)
376 | {
377 | cell.SetRowNumber(row);
378 | cell.transform.SetParent(tableViewScroll.Content, false);
379 |
380 | float cellSize = cellSizes.SizeForRow(row) - ((row > 0) ? tableViewLayout.Spacing : 0);
381 | CreateLayoutIfNeededForCellWithSize(cell, cellSize);
382 |
383 | cell.DidHighlightEvent.RemoveListener(CellDidHighlight);
384 | cell.DidHighlightEvent.AddListener(CellDidHighlight);
385 |
386 | cell.DidSelectEvent.RemoveListener(CellDidSelect);
387 | cell.DidSelectEvent.AddListener(CellDidSelect);
388 |
389 | visibleCells.SetCellAtIndex(row, cell);
390 |
391 | if (atEnd)
392 | {
393 | cell.transform.SetSiblingIndex(tableViewScroll.Content.childCount - 2);
394 | }
395 | else
396 | {
397 | cell.transform.SetSiblingIndex(1);
398 | }
399 |
400 | return cell;
401 | }
402 |
403 | private void RemoveCell(bool last)
404 | {
405 | int row = last ? visibleCells.Range.Last() : visibleCells.Range.from;
406 | TableViewCell removedCell = visibleCells.GetCellAtIndex(row);
407 | removedCell.DidHighlightEvent.RemoveListener(CellDidHighlight);
408 | reusableCells.AddReusableCell(removedCell);
409 | visibleCells.RemoveCellAtIndex(row);
410 | visibleCells.Range.count -= 1;
411 |
412 | if (!last)
413 | {
414 | visibleCells.Range.from += 1;
415 | }
416 | }
417 |
418 | private void CreateLayoutIfNeededForCellWithSize(TableViewCell cell, float size)
419 | {
420 | LayoutElement layoutElement = cell.GetComponent();
421 |
422 | if (layoutElement == null)
423 | {
424 | layoutElement = cell.gameObject.AddComponent();
425 | }
426 |
427 | layoutElement.preferredHeight = 0;
428 | layoutElement.preferredWidth = 0;
429 |
430 | if (isVertical)
431 | {
432 | layoutElement.preferredHeight = size;
433 | }
434 | else
435 | {
436 | layoutElement.preferredWidth = size;
437 | }
438 | }
439 |
440 | private void UpdatePaddingElements()
441 | {
442 | Range startRange = new Range(0, visibleCells.Range.from);
443 | float startSize = cellSizes.SumWithRange(startRange);
444 |
445 | Range endRange = new Range(visibleCells.Range.from, visibleCells.Range.Last() + 1);
446 | float hiddenElementsSizeSum = startSize + cellSizes.SumWithRange(endRange);
447 | float endSize = tableViewScroll.Size - hiddenElementsSizeSum;
448 | endSize -= tableViewLayout.StartPadding;
449 | endSize -= tableViewLayout.EndPadding;
450 | endSize -= tableViewLayout.Spacing;
451 |
452 | tableViewPlaceHolders.UpdatePlaceHoldersWithSize(startSize, endSize);
453 | }
454 |
455 | private IEnumerator AnimateToPosition(float newPosition, float time)
456 | {
457 | float startTime = Time.time;
458 | float initialPosition = position;
459 | float endTime = startTime + time;
460 |
461 | while (Time.time < endTime)
462 | {
463 | float relativeProgress = Mathf.InverseLerp(startTime, endTime, Time.time);
464 | SetPosition(Mathf.Lerp(initialPosition, newPosition, relativeProgress));
465 | yield return new WaitForEndOfFrame();
466 | }
467 |
468 | SetPosition(newPosition);
469 | }
470 |
471 | private void CellDidHighlight(int row)
472 | {
473 | if (tableViewDelegate != null)
474 | {
475 | tableViewDelegate.TableViewDidHighlightCellForRow(this, row);
476 | }
477 |
478 | if (scrollToHighlighted)
479 | {
480 | MakeVisibleRowIfNeeded(row);
481 | }
482 | }
483 |
484 | private void CellDidSelect(int row)
485 | {
486 | if (tableViewDelegate != null)
487 | {
488 | tableViewDelegate.TableViewDidSelectCellForRow(this, row);
489 | }
490 | }
491 |
492 | private void MakeVisibleRowIfNeeded(int row)
493 | {
494 | ScrollToStartIfNeededWithRow(row);
495 | ScrollToEndIfNeededWithRow(row);
496 | }
497 |
498 | private void ScrollToStartIfNeededWithRow(int row)
499 | {
500 | float rowStart = PositionForRow(row);
501 |
502 | if (row == 0)
503 | {
504 | rowStart -= tableViewLayout.StartPadding;
505 | }
506 |
507 | if (position > rowStart)
508 | {
509 | SetPosition(rowStart, scrollingSpeed);
510 | }
511 | }
512 |
513 | private void ScrollToEndIfNeededWithRow(int row)
514 | {
515 | float rowStart = PositionForRow(row);
516 | float rowSize = cellSizes.SizeForRow(row);
517 | float rowEnd = rowStart + rowSize + tableViewLayout.Spacing;
518 | float contentEndPosition = position + tableViewSize;
519 | int rowsCount = cellSizes.RowsCount - 1;
520 |
521 | if (row == rowsCount)
522 | {
523 | rowEnd += tableViewLayout.EndPadding;
524 | }
525 |
526 | if (rowEnd > tableViewScroll.Size)
527 | {
528 | rowEnd = tableViewScroll.Size;
529 | }
530 |
531 | if (rowEnd > contentEndPosition)
532 | {
533 | float rowEndPosition = rowEnd - tableViewSize;
534 | SetPosition(rowEndPosition, scrollingSpeed);
535 | }
536 | }
537 |
538 | #endregion
539 | }
540 | }
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
272 |
273 |
274 |
275 |
276 | true
277 | DEFINITION_ORDER
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 | project
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 | project
457 |
458 |
459 | true
460 |
461 |
462 |
463 | DIRECTORY
464 |
465 | false
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 | 1495184885107
491 |
492 |
493 | 1495184885107
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 |
1100 |
1101 |
1102 |
1103 |
1104 |
1105 |
1106 |
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1161 |
1162 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 |
1177 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1258 |
1259 |
1260 |
1261 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 |
1272 |
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1284 |
1285 |
1286 |
1287 |
1288 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 |
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 |
1305 |
1306 |
1307 |
1308 |
1309 |
1310 |
1311 |
1312 |
1313 |
1314 |
1315 |
1316 |
1317 |
--------------------------------------------------------------------------------