透明小地图&列表点击切换&海拔图头像位移
This commit is contained in:
1 parent
bf48989a9c
commit
6ec4c0101b
114 files changed
+12787
-6517
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using PolyAndCode.UI;
|
||||
|
||||
//Cell class for demo. A cell in Recyclable Scroll Rect must have a cell class inheriting from ICell.
|
||||
//The class is required to configure the cell(updating UI elements etc) according to the data during recycling of cells.
|
||||
//The configuration of a cell is done through the DataSource SetCellData method.
|
||||
//Check RecyclableScrollerDemo class
|
||||
public class DemoCell : MonoBehaviour, ICell
|
||||
{
|
||||
//UI
|
||||
public Text nameLabel;
|
||||
public Text genderLabel;
|
||||
public Text idLabel;
|
||||
|
||||
//Model
|
||||
private ContactInfo _contactInfo;
|
||||
private int _cellIndex;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//Can also be done in the inspector
|
||||
GetComponent<Button>().onClick.AddListener(ButtonListener);
|
||||
}
|
||||
|
||||
//This is called from the SetCell method in DataSource
|
||||
public void ConfigureCell(ContactInfo contactInfo,int cellIndex)
|
||||
{
|
||||
_cellIndex = cellIndex;
|
||||
_contactInfo = contactInfo;
|
||||
|
||||
nameLabel.text = contactInfo.Name;
|
||||
genderLabel.text = contactInfo.Gender;
|
||||
idLabel.text = contactInfo.id;
|
||||
}
|
||||
|
||||
|
||||
private void ButtonListener()
|
||||
{
|
||||
Debug.Log("Index : " + _cellIndex + ", Name : " + _contactInfo.Name + ", Gender : " + _contactInfo.Gender);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f121448b2a47409ba4620601b320879
|
||||
timeCreated: 1577787416
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using PolyAndCode.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Demo controller class for Recyclable Scroll Rect.
|
||||
/// A controller class is responsible for providing the scroll rect with datasource. Any class can be a controller class.
|
||||
/// The only requirement is to inherit from IRecyclableScrollRectDataSource and implement the interface methods
|
||||
/// </summary>
|
||||
|
||||
//Dummy Data model for demostraion
|
||||
public struct ContactInfo
|
||||
{
|
||||
public string Name;
|
||||
public string Gender;
|
||||
public string id;
|
||||
}
|
||||
|
||||
public class RecyclableScrollerDemo : MonoBehaviour, IRecyclableScrollRectDataSource
|
||||
{
|
||||
[SerializeField]
|
||||
RecyclableScrollRect _recyclableScrollRect;
|
||||
|
||||
[SerializeField]
|
||||
private int _dataLength;
|
||||
|
||||
//Dummy data List
|
||||
private List<ContactInfo> _contactList = new List<ContactInfo>();
|
||||
|
||||
//Recyclable scroll rect's data source must be assigned in Awake.
|
||||
private void Awake()
|
||||
{
|
||||
InitData();
|
||||
_recyclableScrollRect.DataSource = this;
|
||||
}
|
||||
|
||||
//Initialising _contactList with dummy data
|
||||
private void InitData()
|
||||
{
|
||||
if (_contactList != null) _contactList.Clear();
|
||||
|
||||
string[] genders = { "Male", "Female" };
|
||||
for (int i = 0; i < _dataLength; i++)
|
||||
{
|
||||
ContactInfo obj = new ContactInfo();
|
||||
obj.Name = i + "_Name";
|
||||
obj.Gender = genders[Random.Range(0, 2)];
|
||||
obj.id = "item : " + i;
|
||||
_contactList.Add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
#region DATA-SOURCE
|
||||
|
||||
/// <summary>
|
||||
/// Data source method. return the list length.
|
||||
/// </summary>
|
||||
public int GetItemCount()
|
||||
{
|
||||
return _contactList.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data source method. Called for a cell every time it is recycled.
|
||||
/// Implement this method to do the necessary cell configuration.
|
||||
/// </summary>
|
||||
public void SetCell(ICell cell, int index)
|
||||
{
|
||||
//Casting to the implemented Cell
|
||||
var item = cell as DemoCell;
|
||||
item.ConfigureCell(_contactList[index], index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c745aeaf787e04d39909d72c86f1aeb9
|
||||
timeCreated: 1579688470
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user