Wrap Content by boris-741 - 1

Games & Projects

Unity Infinitie Scroll example

Unknown VersionMIT LicenseUpdated 15 days agoCreated on May 12th, 2020
Go to source

Wrap Content

Example for creating GUI elements using LeoECS and Unity3d

thanks leo GitHub Pages

screenshot_0 screenshot_1 screenshot_2

  1. create data structure. example:
public struct CustomWrapItemData
{
    public string str;
}
  1. create an inheritor class from MonoBehaviour and override interface IBaseItem functions this is for scroll item element
public class WrapItem : MonoBehaviour, IBaseItem<CustomWrapItemData>
{
    public int index{set; get;} 
    public void SetData(int index, ref T data){}
    public void SetSize(float size){}
    public void SetAction(ViewAction action){}
    public void SetAction(float tm_action, float tm_cur, ViewAction action){}
    public void Show(bool show){}
}
  1. create an inheritor class from BaseWrapContent - this is scroll class GetItemSize - return size of scroll item
public class CustomWrapContent:  BaseWrapContent<CustomWrapItemData, WrapItem>
{
    protected override float GetItemSize(CustomWrapItemData data)
    {
        return 60f;
    }
}

see scene example

Show all projects by boris-741