All Projects → Mukarillo → Unitydynamicscrollrect

Mukarillo / Unitydynamicscrollrect

Licence: mit
An optimized approach to lists with dozens of elements and a Pooling system

Projects that are alternatives of or similar to Unitydynamicscrollrect

Unity Script Collection
A maintained collection of useful & free unity scripts / library's / plugins and extensions
Stars: ✭ 3,640 (+2218.47%)
Mutual labels:  unity, unity3d-plugin, unity2d
Unitylibrary
📚 Library of all kind of scripts, snippets & shaders for Unity
Stars: ✭ 1,968 (+1153.5%)
Mutual labels:  unity, unity3d-plugin, unity2d
Uicard
Generic UI for card games like Hearthstone, Magic Arena and Slay the Spire...
Stars: ✭ 142 (-9.55%)
Mutual labels:  unity, unity2d, ui-components
Apple Signin Unity
Unity plugin to support Sign In With Apple Id
Stars: ✭ 228 (+45.22%)
Mutual labels:  unity, unity3d-plugin, unity2d
Jengine
JEngine是针对Unity开发者设计的开箱即用的框架,封装了强大的功能,小白也能快速上手,轻松制作可以热更新的游戏 | JEngine is a streamlined and easy-to-use framework designed for Unity Programmers which contains powerful features, beginners can start up quickly and making hot update-able games easily
Stars: ✭ 564 (+259.24%)
Mutual labels:  unity, unity3d-plugin, unity2d
Savegamepro
A Complete and Powerful Save Game Solution for Unity (Game Engine)
Stars: ✭ 30 (-80.89%)
Mutual labels:  unity, unity3d-plugin, unity2d
Unity Scriptableobjects Game Events
Based on a great talk by Ryan Hipple, here is my improved version of his Game Event system for Unity
Stars: ✭ 121 (-22.93%)
Mutual labels:  unity, unity3d-plugin, unity2d
Uia 2e
all the projects from Unity in Action 2nd edition
Stars: ✭ 97 (-38.22%)
Mutual labels:  unity, unity2d
Ugui Tween Tool
unity4.6.x && unity5.x ugui tween utools
Stars: ✭ 99 (-36.94%)
Mutual labels:  unity, unity3d-plugin
Unity Ui Examples
📚 A collection of UI examples for Unity.
Stars: ✭ 152 (-3.18%)
Mutual labels:  unity, unity2d
Impulse
A barebones C# bootstrap framework for building scalable projects quickly and easily in Unity.
Stars: ✭ 109 (-30.57%)
Mutual labels:  unity, unity2d
Darkconfig
DarkConfig is a configuration library for games which supports fast and expressive iteration
Stars: ✭ 94 (-40.13%)
Mutual labels:  unity, unity3d-plugin
Play
The free and open source karaoke singing game UltraStar Play for Windows, Linux, Android, Xbox, PlayStation and other platforms.
Stars: ✭ 94 (-40.13%)
Mutual labels:  unity, unity2d
Succ
Sexy and Utilitarian Code Configuration
Stars: ✭ 100 (-36.31%)
Mutual labels:  unity, unity3d-plugin
Spriteglow
A sprite glow effect for Unity game engine
Stars: ✭ 1,287 (+719.75%)
Mutual labels:  unity, unity3d-plugin
Unity Animator Helpers
A micro-framework for changing Unity 3D's Animator parameters with ScriptableObject(s). Designed to make going from custom scripts to Animator parameters easy. Works with 2D or 3D projects.
Stars: ✭ 89 (-43.31%)
Mutual labels:  unity, unity2d
Csharp Eval Unity3d
C# Expression Parser for Unity3D
Stars: ✭ 102 (-35.03%)
Mutual labels:  unity, unity3d-plugin
Ma textureatlasser
Texture atlas creator for Unity
Stars: ✭ 116 (-26.11%)
Mutual labels:  unity, unity3d-plugin
Newbark
🌳 A proof-of-concept Pokémon-style Retro RPG engine created with Unity.
Stars: ✭ 129 (-17.83%)
Mutual labels:  unity, unity2d
U.movin
Unity library for rendering After Effects shape animations
Stars: ✭ 122 (-22.29%)
Mutual labels:  unity, unity2d

UnityDynamicScrollRect

An optimized approach to lists with dozens of elements.

Example

How to use

you can find a pratical example inside this repository in DynamicScrollScene scene

1 - Create a class to store all the information that each element of the list will need.

public class ExampleData
{
      public int postId;
      public int id;
      public string name;
      public string email;
      public string body;
}

2 - Create a class that extends DynamicScrollObject<ExampleData> and implement its abstract members (make sure to call base.updateScrollObject(item, index);) and set the object width and height in currentWidth and currentHeight.

public class ExampleDynamicObject : DynamicScrollObject<ExampleData>
{
  public override float currentHeight { get; set; }
  public override float currentWidth { get; set; }

  private Text idText;
  private Text nameEmailText;
  private Text bodyText;

  public void Awake()
  {
    currentHeight = GetComponent<RectTransform>().rect.height;
    currentWidth = GetComponent<RectTransform>().rect.width;

    idText = transform.Find("PostId").GetComponent<Text>();
    nameEmailText = transform.Find("NameEmail").GetComponent<Text>();
    bodyText = transform.Find("Body").GetComponent<Text>();         
  }

  public override void updateScrollObject(ExampleData item, int index)
  {
    base.updateScrollObject(item, index);

    idText.text = item.id.ToString();
    nameEmailText.text = string.Format("{0} ({1})", item.name, item.email);
    bodyText.text = item.body;
  }
}

3 - Create a class to initiate the DynamicList (use DynamicScrollRect instead of ScrollRect)

public class ExampleScroll : MonoBehaviour
{
  public DynamicScrollRect verticalScroll;
  public GameObject referenceObject;

  private DynamicScroll<ExampleData, ExampleDynamicObject> mVerticalDynamicScroll = new DynamicScroll<ExampleData, ExampleDynamicObject>();

  public IEnumerator Start()
  {
    WWW www = new WWW(@"https://jsonplaceholder.typicode.com/comments");
    yield return www;
    var data = JsonHelper.getJsonArray<ExampleData>(www.text);

    mVerticalDynamicScroll.spacing = 5f;
    mVerticalDynamicScroll.Initiate(verticalScroll, data, 0, referenceObject);
  }      
}

DynamicScroll<T, T1> public overview

Properties

name type description
spacing float Value that represent the spacing between elements of the list
centralizeOnStop bool If the list should centralize the closest element to the center of the viewport after stop moving
objectPool readonly Pooling < T1 > The elements of the list
OnDragEvent Action < Vector2 > Event that triggers whenever the user scrolls the list, the parameter represent the velocity of the drag
OnBeginDragEvent UnityEvent < PointerEventData > Event that triggers in the first frame of dragging
OnEndDragEvent UnityEvent < PointerEventData > Event that triggers in the last frame of dragging

Methods

dynamicScroll.Initiate

  • Description: Initiate the scroll rect with objReference objects applying infoList data.

  • Parameters:

name type description
scrollRect ScrollRect a reference to the scroll rect
infoList T[] the list with the data information
startIndex int the item of index startindex will be the first element of the list
objReference GameObject a reference of the object that will be inside the list
createMoreIfNeeded bool if the list needs more itens, it will create more if createMoreIfNeeded == true
forceAmount int? if setted, it will force forceAmount objects to be created at start

dynamicScroll.ChangeList

  • Description: Change the current list of the scroll rect.

  • Parameters :

name type description
infoList T[] the list with the data information
startIndex int the item of index startindex will be the first element of the list. If -1, the current index will be setted.
resetContentPosition bool reset list position

dynamicScroll.RefreshPosition

  • Description: Repaint the whole scroll rect. This is useful if any item inside the scroll rect changes the size (currentWidth and currentHeight).

dynamicScroll.ToggleScroll

  • Description: Enable or Disable the ability to scroll the list.

  • Parameters :

name type description
active bool enable or Disable the ability to scroll the list

dynamicScroll.CanMove

  • Description: Returns true if all directions send thro parameter are available.

  • Parameters :

name type description
directions ScrollDirection Enum flag with all the directions you want to know if are available

dynamicScroll.MoveToIndex

  • Description: Tweens the content to centralize the object of index specified in the parameters.

  • Parameters :

name type description
i int Index of the element to be centralized
totalTime float? Total time to the animation happen (if you choose to input this value, the next one will be ignored)
timePerElement float? This value will be multiplied by the difference between the current centralized element and the target element to get the totalTime

dynamicScroll.GetCentralizedObject

  • Description: Returns the closest element to the center of the viewport.

dynamicScroll.GetLowest

  • Description: Returns the most left (if horizontal scroll) or most bottom (if vertical scroll) T1 object.

dynamicScroll.GetHighest

  • Description: Returns the most right (if horizontal scroll) or most upper (if vertical scroll) T1 object.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].