Skip to main content
Version: v3

Module Introduction

Important Attention Reminder

Coding Style wiki


Basic Introduction

Core module (linked with AssetLoader for automatic unloading), covering the creation of main game objects and implementing object naming and binding functionality.

  • Game UI (UIFrame, UI = User Interface), supports object naming and binding. Starts with underscore _Node@XXX
  • Scene Resources (SRFrame, SR = Scene Resource), supports object naming and binding. Starts with underscore _Node@XXX
  • Unity Scene (USFrame, US = Unity Scene)
  • Template Objects (CPFrame, CP = Clone Prefab), supports object naming and binding. Starts with tilde ~Node@XXX

How to Use

UIFrame (User Interface)

Used to manage UI Prefabs, supports only UGUI, with UIManager handling objects mounted with UIBase.

  • Supports UI reverse changes (Reverse Changes).
  • Supports UI stack-based closing (Close Stack By Stack).
  • Supports UI freeze functionality to prevent event triggers from clicks during incomplete UI animations.

Reminder To create UI animations, override ShowAnimation and HideAnimation to execute relevant transition animations (DoTween, Animation...), and ensure to call the animationEnd() callback correctly after completing the UI animation to properly release the UI freeze state.

Reminder Additionally, UI MaskEvent is available, which can also be customized by overriding.

UI Reverse Changes UsageUI Reverse Changes Usage
UI Close Stack By Stack UsageUI Close Stack By Stack Usage

SRFrame (Scene Resource)

Used to manage Scene Prefabs and Function Prefabs, with SRManager handling objects mounted with SRBase.

USFrame (Unity Scene)

Used to manage Unity Scene, with USManager handling Unity scenes (supports AssetBundle).

Attention Using the build# prefix will switch to loading from Build Settings -> Scenes In Build. Otherwise, AssetBundle is used.

CPFrame (Clone Prefab)

Used to instantiate Prefab template objects, with CPManager handling Prefabs mounted with CPBase. Primarily used for loading template objects, such as item icon templates, mail message templates, etc. Directly performing GameObject.Destroy will automatically execute reference counting unloading.

Reminder CPManager does not perform caching for CPBase.

Common Method Descriptions

  • OnCreate: Used for initializing parameters.
  • OnBind: Used for initializing events.
  • OnPreShow: When there is asynchronous processing or control of dependent objects, it can be handled here. For example: If TopUI is linked to open LeftUI & RightUI, you can implement Show LeftUI & RightUI in the OnPreShow method of TopUI.
    • Reminder It is not recommended to handle Show-related processing in OnPreClose. If it is done, it’s fine, as the CloseAll API provides a disabledPreClose parameter switch.
  • OnShow: This method is activated when Show is called, and data can be passed through the provided object.
  • OnClose: This method is activated when Close is called.
  • OnRelease: This method is activated when the object is Destroyed.

Initialization Order Description

Important OnCreate (Once) > OnAutoBind (Once) > OnBind (Once) > OnPreShow (EveryOpen) > OnShow (EveryOpen).

Object Binding Description

  • Use collector.GetNode("BindName") to return a bound GameObject (single name binding).
    • UIBase & SRBase use _Node@XXX.
    • CPBase uses ~Node@XXX.
  • Use collector.GetNodes("BindName") to return bound GameObject[] (multiple bindings with the same name, ordered from top to bottom).
    • UIBase & SRBase use _Node@XXX.
    • CPBase uses ~Node@XXX.
  • Use collector.GetNodeComponent<TComponent>("BindName") to return a bound TComponent (single name binding).
    • UIBase & SRBase use _Node@XXX.
    • CPBase uses ~Node@XXX.
  • Use collector.GetNodeComponents<TComponent>("BindName") to return bound TComponent[] (multiple bindings with the same name, ordered from top to bottom).
    • UIBase & SRBase use _Node@XXX.
    • CPBase uses ~Node@XXX.

Auto-Generate Stop Binding Tag (Hotkey: Shift+E, E: End)

Reminder Using the Hotkey is recommended, as Right-Click may execute multiple times (does not affect auto-generation), but this is a Unity Bug that Unity officially will not fix.

Reduces the number of downward searches for bindings during Runtime, with a time complexity of O(N), where N = StopEndIdx (recommended for scenarios with a large number of node objects).

  • Important If Transform.Find is used to search for child objects and the child object name contains a # tag, it can be ignored, as during Runtime, the # tag will be replaced with "" to restore the original name.

Auto-Generate Object Binding Code (Hotkey: Shift+B, B: Bind)

Naming convention uses * to point to TailName

  • UIBase & SRBase
    • _Node@XXX*Btn (and so on)
  • CPBase
    • ~Node@XXX*Btn (and so on)

Auto-Binding Description

Auto-Binding Configuration

Default Component Binding Table (You can add or modify TailName corresponding to binding component types from BindCodeSetting)

Tail NameComponent NameEnd Remove CountEnd Plural Txt
Other
TransTransform0es
RectTransRectTransform0es
Legacy
ImgImage0s
RawImgRawImage0s
TxtText0s
BtnButton0s
TglToggle0s
SldSlider0s
ScrBarScrollbar0s
ScrViewScrollRect0s
DrdDropdown0s
FieldInputField0s
TMP
TmpTxtTMP_Text0s
TmpDrdTMP_Dropdown0s
TmpFieldTMP_InputField0s
Custom
BtnPlusButtonPlus0es
NodePoolNodePool0s

The auto-binding generator's functionality is distinguished by method types, as follows:

  • Auto [Default], automatically saves binding content to the code, overriding and calling OnAutoBind() automatically.

  • Manual [Optional], manually copies binding content to the code, overriding and calling OnAutoBind() automatically.