Skip to content
Aprius edited this page Aug 28, 2024 · 16 revisions

UIButton

You can create empty UIButton via menu Right Click > Pancake > UIButton

image

image

  • TypeClick

    • OnlySingleClick : Only executed single click.
    • OnlyDoubleClick : Only executed double click
    • LongClick : (single click or long click), Execute button onClick event after a period of time. If onLongClick is already called then onClick will not be called again when you release your hand remove double click executed.
    • Instant : Normal click type (single click + double click). Single click will get executed before a double click (dual actions)
    • Delayed : If it's a double click, the single click will not executed use this if you want to make sure single click not execute before a double click the downside is that there is a delay when executing the single click (the delay is the double click register interval)
    • Hold : (single click or hold) Execute button onClick event as normal If hold is already called then onClick will not be called again when you release your hand remove double click executed
  • Additional field depending on type click

    • OnlySingleClick
      • Multiple Click : If true, button can spam clicked and it not get disabled
    • OnlyDoubleClick, Instant, Delayed
      • Duration : time detected double click in seconds
    • LongClick
      • Duration : time detected long click in seconds
    • Hold
      • Duration : time detected hold in seconds
  • Ignore Time Scale: Does time scale affect button motion?

  • Affect To Self : Motion affects the button itself or another specified object

  • Is Play Sound : Pass in an AudioStructure to play the sound when the button is pressed

  • Use Motion : Is the button allowed to have an animation effect?

  • Motion Type

    • Immediate : No movement, value is changed instantly
    • Normal : Motion is separated between Down and Up
    • Uniform : Continuous motion as soon as the mouse is pressed down and automatically ends the cycle, no movement when releasing the mouse
    • Late : Continuous motion as soon as the mouse is released and automatically ends the cycle, no motion when pressing down at first
  • Scale : percentage divided by 100 of scale

  • Duration : motion up time as well as motion down time in seconds

  • Ease : Easing of motion

  • Unable Interact : allow motion when button interacable is false

Usages

Similar to Unity's Button because UIButton inherits from Unity's Button

Navigator

  1. Basic structure

It consists of a UIView and a UIContainer to place the corresponding UIViews. UIView and UIContainer are composed of Sheet, Page, Popup, and SheetContainer, PageContainer, and PopupContainer, respectively. Each UIView must be placed as a child object of the appropriate UIContainer. In addition, game objects corresponding to each UIView must add objects that inherit UIView appropriate for their purpose as components.

 1-1. Features of Sheet

 1) History is not managed
 2) History management of lower level UIViews
 3) Only one container is activated at a time
 4) Placed in the scene in advance


 1-2. Features of Page

 1) History is managed
 2) Only one container is activated at a time
 3) Placed in the scene in advance


 1-3. Features of Modal

 1) History is managed
 2) Can be activated by overlapping at once on a container basis.
 3) Instead of placing it in the scene in advance, register the prefab in the inspector in ModalContainer and use it.
public sealed class SettingPopup : Popup<SettingView>{}

public sealed class SettingView : View
{
   protected override UniTask Initialize()
   {
       // todo
       return UniTask.CompletedTask;
   }
}

You can create this via template by button Create Type

image

  • You can use AssetLoader to get the prefab of page, sheet or popup. There are 3 types of asset loaders:

    • Resources : Need place prefab into Resources folder
    • Preloaded : Need drag prefab into list preload object of preload asset
    • Addressables : Need mark prefab as addressable (recommend)

you can create asset loader via menu Create > Pancake > AssetLoader

RecyclerView

public sealed class CountryElementCellModel : CellModel{}

public class CountryElementCell : Cell<CountryElementCellModel>
{
  protected override void SetModel(CountryElementCellModel model){}
}

public class Demo : MonoBehaviour, IRecyclerViewCellProvider, IRecyclerViewDataProvider
{
   private RecyclerView _recyclerView;
   private readonly List<CountryElementCellModel> _datas = new();

   private RecyclerView RecyclerView
   {
      get
       {
            if (_recyclerView == null)
            {
                    _recyclerView = countryPopup.GetComponentInChildren<RecyclerView>();
                    _recyclerView.DataCount = 0;
                    _recyclerView.CellProvider = this;
                    _recyclerView.DataProvider = this;
             }

             return _recyclerView;
         }
    }

    private void Start()
    {
      // init data
      RecyclerView.DataCount = _datas.Count;
      RecyclerView.RefreshData();
    }
   
     public GameObject GetCell(int dataIndex) 
     {  
        // todo return cell
     }

     public void ReleaseCell(GameObject cell) { cell.Return(); }

     public void SetupCell(int dataIndex, GameObject cell) { cell.GetComponent<ICell>().Setup(_datas[dataIndex]); }
}
Clone this wiki locally