Trigger API Reference DCEI Functions Custom UI0 - BLKTower/TestWiki GitHub Wiki

Table of Contents

Trigger API Reference\DCEI Functions\Custom UI (1/8) {Trigger-API-ReferenceDCEI-FunctionsCustom-UI-18}

  • UI frames will either have a default size of 0 and expand to fit any children or attempt to fill their parent.
  • Placing a frame that attempts to fill its parent inside a frame with a default size of 0 will cause the parent frame to expand to fill their parent.

See Also

Transform GetUiRootFrame() {Transform-GetUiRootFrame}

Transform GetUiRootFrame()

Description

Returns the root UI frame.

Example Usage

local ui_root = DCEI.GetUiRoot()

Float2 GetUiCanvasSize(bool ignoreSafeArea) {Float2-GetUiCanvasSizebool-ignoreSafeArea}

Float2 GetUiCanvasSize(bool ignoreSafeArea)

Description

Returns the UI canvas size.

Parameters

  • bool ignoreSafeArea if true, ignores any safe areas.

Example Usage

local ui_canvas_size = DCEI.GetUiCanvasSize(true)
DCEI.LogMessage("UI canvas X dim: " .. ui_canvas_size.x .. " Y dim: " .. ui_canvas_size.y)

float SetUiSizeMultiplier(float multiplier) {float-SetUiSizeMultiplierfloat-multiplier}

float SetUiSizeMultiplier(float multiplier)

Description

Applies a multiplier to all size parameters of all custom UI frames. This was added to help migrate legacy maps to portrait mode, due to the canvas scaling change.

Parameters

  • float multiplier the global multiplier to apply to all custom UI.

Example Usage

local multiplier = 16/9
DCEI.SetUiSizeMultiplier(multiplier)

Transform GetUiRootFrameForPlayer(int player) {Transform-GetUiRootFrameForPlayerint-player}

Transform GetUiRootFrameForPlayer(int player)

Description

Returns the root UI frame for the given player.

Parameters

  • int player the player to return the root UI frame for.

Example Usage

local ui_root = DCEI.GetUiRootForPlayer(1)

void DestroyFrame(Transform ui) {void-DestroyFrameTransform-ui}

void DestroyFrame(Transform ui)

Description

Destroys the given UI frame and all its children.

Parameters

  • Transform ui the UI frame to destroy.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.Destroy(frame)

bool FrameExists(Transform ui) {bool-FrameExistsTransform-ui}

bool FrameExists(Transform ui)

Description

Returns true if the given UI exists.

Parameters

  • Transform ui the UI frame to check.

Example Usage

local ui_exists = DCEI.UiExists(DCEI.GetUiRoot())
DCEI.LogMessage("Root UI exists: " .. tostring(ui_exists))

Transform GetParentFrame(Transform item) {Transform-GetParentFrameTransform-item}

Transform GetParentFrame(Transform item)

Description

Returns the parent frame of the given UI frame.

Parameters

  • Transform item the UI frame to return the parent frame of.

Example Usage

local parent_frame = DCEI.GetParentFrame(frame)

Transform CreateFrame(Transform parent) {Transform-CreateFrameTransform-parent}

Transform CreateFrame(Transform parent)

Description

Creates and returns a new frame as a child of the given a parent frame. This frame has a default height/width of 0 and expands to fit any children.

Parameters

  • Transform parent the parent frame.

Example Usage

-- creates a red square
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 200, 200)
DCEI.SetBackgroundImageColor(frame, 1, 0, 0, 1)

float GetFrameWidth(Transform ui) {float-GetFrameWidthTransform-ui}

float GetFrameWidth(Transform ui)

Description

Returns the width of a UI frame. Note that UI frame size changes are applied at the end of a game update, so you'd need to wait a frame after changing the size of a UI frame to get the new dimensions.

Parameters

  • Transform ui the UI frame.

Example Usage

local root_width = DCEI.GetFrameWidth(DCEI.GetUiRoot())
DCEI.LogMessage("The width of the root UI frame is: " .. root_width)

float GetFrameHeight(Transform ui) {float-GetFrameHeightTransform-ui}

float GetFrameHeight(Transform ui)

Description

Returns the height of a UI frame. Note that UI frame size changes are applied at the end of a game update, so you'd need to wait a frame after changing the size of a UI frame to get the new dimensions.

Parameters

  • Transform ui the UI frame.

Example Usage

local root_height = DCEI.GetFrameHeight(DCEI.GetUiRoot())
DCEI.LogMessage("The height of the root UI frame is: " .. root_height)

void SetFrameUseImageSizeRatio(Transform ui, float ratio) {void-SetFrameUseImageSizeRatioTransform-ui-float-ratio}

void SetFrameUseImageSizeRatio(Transform ui, float ratio)

Description

Makes the given UI frame set its sized based on the texture used for it's background image. This ratio determines the rendering size of the frame, where 1 will use the original dimensions of the texture. Once set, setting either height or width (but not both) will adjust the other dimension proportionally to match the size ratio.

Parameters

  • Transform ui the UI frame.
  • float ratio the image size ratio.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.UseImageSizeRatio(frame, 2)

Related

void SetFrameAlpha(Transform ui, float alpha) {void-SetFrameAlphaTransform-ui-float-alpha}

void SetFrameAlpha(Transform ui, float alpha)

Description

Sets the transparency for the given UI frame and all of its children. This option with have a compounding effect with an alpha value set by SetBackgroundImageColor(). Child frames cannot be made less transparent than their parent with this function.

Parameters

  • Transform ui the UI frame.
  • float alpha the frame transparency, from 0 to 1, where 0 is transparent and 1 is opaque.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 200, 200)
DCEI.SetBackgroundImageColor(frame, 1, 0, 0, 1)
DCEI.SetFrameAlpha(frame, 0.5)

Transform CreateMaskFrame(Transform parent) {Transform-CreateMaskFrameTransform-parent}

Transform CreateMaskFrame(Transform parent)

Description

Creates a mask. Masks can be used to 'crop' child frames to the masks size/shape. If given a background image, the opaque white pixels will be used to determine the shape of the effect. By default, this frame type attempts to fill its parent size unless given explicit dimensions.

Parameters

  • Transform parent the parent frame.

Example Usage

-- mask's its children using a circle texture
local mask = DCEI.NewMask(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(mask, "circle_mask")
DCEI.SetSize(mask, 150, 150)
    
-- frame to mask (note the original texture is square)
local frame = DCEI.NewFrame(mask)
DCEI.SetBackgroundImage(frame, "question_green")
DCEI.SetSize(frame, 200, 200)

Related

Transform CreateStencilMaskFrame(Transform parent) {Transform-CreateStencilMaskFrameTransform-parent}

Transform CreateStencilMaskFrame(Transform parent)

Description

Creates a stencil mask. Stencil masks can be used to 'cut holes' in a parent mask frame. Similar to a mask frame, if given a background image, the white/opaque values will be used to determine the shape of the effect. A stencil mask will also cut through any of its sibling frames. By default, this frame type attempts to fill its parent size unless given explicit dimensions.

Parameters

  • Transform parent the parent frame.

Example Usage

-- fullscreen mask that can be used by the stencil
local mask = DCEI.NewMask(DCEI.GetUiRoot())

-- stencil used to cut out a section from the mask and its children
local stencil = DCEI.NewStencilMask(mask)
DCEI.SetSize(stencil, 100, 100)
DCEI.SetBackgroundImage(stencil, "circle_mask")

-- this frame will be affected by the stencil
local frame_to_stencil = DCEI.NewFrame(mask)
DCEI.SetMatchParent(frame_to_stencil, true, true)
DCEI.SetBackgroundImageColor(frame_to_stencil, 0, 0, 0, 0.5)

Related

Transform CreateHighlightFrame(Transform parent) {Transform-CreateHighlightFrameTransform-parent}

Transform CreateHighlightFrame(Transform parent)

Description

Creates a highlight frame. If the highlight is given a background image, it will animate a highlight effect across the texture; otherwise the highlight will display a simple animation around its border. This frame type has a default size of 0 and expands to fit any children.

Parameters

  • Transform parent the parent frame.

Example Usage

local highlight = DCEI.NewHighlight(DCEI.GetUiRoot())
local frame = DCEI.NewFrame(highlight)
DCEI.SetSize(frame, 100, 100)

Transform CreateCameraFrame(Transform parent) {Transform-CreateCameraFrameTransform-parent}

Transform CreateCameraFrame(Transform parent)

Description

Creates a new camera frame. Camera frames can be used to project views of the game world onto a UI frame. This can be used to make animated portraits using in-game models, among other uses. Requires the use of helper functions to set default values.

Parameters

  • Transform parent the parent frame.

Example Usage

-- create unit
DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 12, 0, -1)

-- create camera frame border
local container = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(container, "frame01")
DCEI.SetPadding(container, 10)
    
-- create camera frame facing our unit
local camera = DCEI.NewCameraFrame(container)
DCEI.SetSize(camera, 150, 150)
DCEI.SetCameraFrameSize(camera, 200, 200, true)
DCEI.SetCameraFramePosition(camera, 16, 1, 11)
DCEI.SetCameraFrameRotation(camera, 35, 0, 0)

Related

Transform CreateVStackFrame(Transform parent) {Transform-CreateVStackFrameTransform-parent}

Transform CreateVStackFrame(Transform parent)

Description

Creates a new vertical stack. This frame will arrange child frames vertically within it. By default, child frames are stacked from top to bottom. This frame type has a default size of 0 and expands to fit any children.

Parameters

  • Transform parent the parent frame.

Example Usage

local stack = DCEI.NewVStack(DCEI.GetUiRoot())
DCEI.SetSize(stack, 200, 600)
DCEI.SetBackgroundImageColor(stack, 0, 0, 1, 0.2)

local frame1 = DCEI.NewFrame(stack)
DCEI.SetSize(frame1, 200, 100)
DCEI.SetBackgroundImageColor(frame1, 1, 1, 0, 0.5)

local frame2 = DCEI.NewFrame(stack)
DCEI.SetSize(frame2, 200, 100)
DCEI.SetBackgroundImageColor(frame2, 1, 0, 1, 0.4)

local frame3 = DCEI.NewFrame(stack)
DCEI.SetSize(frame3, 200, 100)
DCEI.SetBackgroundImageColor(frame3, 1, 0, 0, 0.6)

local frame4 = DCEI.NewFrame(stack)
DCEI.SetSize(frame4, 200, 100)
DCEI.SetBackgroundImageColor(frame4, 1, 1, 1, 0.3)

local frame5 = DCEI.NewFrame(stack)
DCEI.SetSize(frame5, 200, 100)
DCEI.SetBackgroundImageColor(frame5, 1, 1, 0, 1)

Related

Transform CreateHStackFrame(Transform parent) {Transform-CreateHStackFrameTransform-parent}

Transform CreateHStackFrame(Transform parent)

Description

Creates a new horizontal stack. This frame will arrange child frames horizontally within it. By default, child frames are stacked from left to right. This frame type has a default size of 0 and expands to fit any children. If this frame is assigned a set size, oversized child frames will overflow.

Parameters

  • Transform parent the parent frame.

Example Usage

local stack = DCEI.NewHStack(DCEI.GetUiRoot())
DCEI.SetBackgroundImageColor(stack, 0, 0, 1, 0.2)
DCEI.SetSize(stack, 600, 100)

local frame1 = DCEI.NewFrame(stack)
DCEI.SetSize(frame1, 100, 100)
DCEI.SetBackgroundImageColor(frame1, 1, 1, 0, 0.5)

local frame2 = DCEI.NewFrame(stack)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 1, 0, 1, 0.4)

local frame3 = DCEI.NewFrame(stack)
DCEI.SetSize(frame3, 100, 100)
DCEI.SetBackgroundImageColor(frame3, 1, 0, 0, 0.6)

local frame4 = DCEI.NewFrame(stack)
DCEI.SetSize(frame4, 100, 100)
DCEI.SetBackgroundImageColor(frame4, 1, 1, 1, 0.3)

local frame5 = DCEI.NewFrame(stack)
DCEI.SetSize(frame5, 100, 100)
DCEI.SetBackgroundImageColor(frame5, 1, 1, 0, 1)

Related

Transform CreateGridFrame(Transform parent) {Transform-CreateGridFrameTransform-parent}

Transform CreateGridFrame(Transform parent)

Description

Creates a new grid. This frame will arrange child frames in a grid by determining the number of rows/columns automatically from the cellWidth and cellHeight properties. This should be followed by SetGridCellHeight() and SetGridCellWidth() to set the aforementioned properties, as it does not have default values for either.

Parameters

  • Transform parent the parent frame.

Example Usage

local grid = DCEI.NewGrid(DCEI.GetUiRoot())
DCEI.SetGridCellHeight(grid, 100)
DCEI.SetGridCellWidth(grid, 100)
DCEI.SetSize(grid, 200, 200)

local content1 = DCEI.NewText(grid)
DCEI.SetText(content1, "a")
DCEI.SetSize(content1, 100, 100)
local content2 = DCEI.NewText(grid)
DCEI.SetText(content2, "b")
DCEI.SetSize(content2, 100, 100)
local content3 = DCEI.NewText(grid)
DCEI.SetText(content3, "c")
DCEI.SetSize(content3, 100, 100)
local content4 = DCEI.NewText(grid)
DCEI.SetText(content4, "d")
DCEI.SetSize(content4, 100, 100)

Related

void SetGridFrameLeftAlignment(Transform ui) {void-SetGridFrameLeftAlignmentTransform-ui}

void SetGridFrameLeftAlignment(Transform ui)

Description

Sets left alignment for a UI frame's contents.

Parameters

  • Transform ui the frame to set content alignment for.

Example Usage

local frame1 = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame1, 200, 200)
DCEI.SetBackgroundImageColor(frame1, 1, 0, 1, 0.4)
DCEI.SetGridFrameLeftAlignment(frame1)

local frame2 = DCEI.NewFrame(frame1)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 0, 1, 1, 0.4)

void SetGridFrameRightAlignment(Transform ui) {void-SetGridFrameRightAlignmentTransform-ui}

void SetGridFrameRightAlignment(Transform ui)

Description

Sets right alignment for a UI frame's contents.

Parameters

  • Transform ui the frame to set content alignment for.

Example Usage

local frame1 = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame1, 200, 200)
DCEI.SetBackgroundImageColor(frame1, 1, 0, 1, 0.4)
DCEI.SetGridFrameRightAlignment(frame1)

local frame2 = DCEI.NewFrame(frame1)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 0, 1, 1, 0.4)

void SetGridFrameHorizontalCenterAlignment(Transform ui) {void-SetGridFrameHorizontalCenterAlignmentTransform-ui}

void SetGridFrameHorizontalCenterAlignment(Transform ui)

Description

Sets horizontal center alignment for a UI frame's contents.

Parameters

  • Transform ui the frame to set content alignment for.

Example Usage

local frame1 = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame1, 200, 200)
DCEI.SetGridFrameHorizontalCenterAlignment(frame1, 1, 0, 1, 0.4)
DCEI.SetTopAlignment(frame1)

local frame2 = DCEI.NewFrame(frame1)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 0, 1, 1, 0.4)

void SetGridFrameTopAlignment(Transform ui) {void-SetGridFrameTopAlignmentTransform-ui}

void SetGridFrameTopAlignment(Transform ui)

Description

Sets top alignment for a UI frame's contents.

Parameters

  • Transform ui the frame to set content alignment for.

Example Usage

local frame1 = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame1, 200, 200)
DCEI.SetGridFrameTopAlignment(frame1, 1, 0, 1, 0.4)
DCEI.SetTopAlignment(frame1)

local frame2 = DCEI.NewFrame(frame1)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 0, 1, 1, 0.4)

void SetGridFrameBottomAlignment(Transform ui) {void-SetGridFrameBottomAlignmentTransform-ui}

void SetGridFrameBottomAlignment(Transform ui)

Description

Sets bottom alignment for a UI frame's contents.

Parameters

  • Transform ui the frame to set content alignment for.

Example Usage

local frame1 = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame1, 200, 200)
DCEI.SetBackgroundImageColor(frame1, 1, 0, 1, 0.4)
DCEI.SetGridFrameBottomAlignment(frame1)

local frame2 = DCEI.NewFrame(frame1)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 0, 1, 1, 0.4)

void SetGridFrameVerticalCenterAlignment(Transform ui) {void-SetGridFrameVerticalCenterAlignmentTransform-ui}

void SetGridFrameVerticalCenterAlignment(Transform ui)

Description

Sets vertical center alignment for a UI frame's contents.

Parameters

  • Transform ui the frame to set content alignment for.

Example Usage

local frame1 = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame1, 200, 200)
DCEI.SetGridFrameVerticalCenterAlignment(frame1, 1, 0, 1, 0.4)
DCEI.SetTopAlignment(frame1)

local frame2 = DCEI.NewFrame(frame1)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 0, 1, 1, 0.4)

Transform CreateHScrollFrame(Transform parent) {Transform-CreateHScrollFrameTransform-parent}

Transform CreateHScrollFrame(Transform parent)

Description

Creates a new horizontal scrolling frame. This frame functions similarly to a HStack, in that it will arrange its child frames horizontally, however this frame also supports horizontal scrolling if the contents would be larger than the size of the scroll frame. Do not place content inside this frame directly, instead use GetScrollContent() to fetch the content frame. By default, this frame type attempts to fill its parent size unless given explicit dimensions.

Parameters

  • Transform parent the parent frame.

Example Usage

local hscroll_frame = DCEI.NewHScroll(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(hscroll_frame, "frame01")
DCEI.SetSize(hscroll_frame, 350, 120)
    
local hscroll_content = DCEI.GetScrollContent(hscroll_frame)
DCEI.SetSpacing(hscroll_content, 10)
DCEI.SetPadding(hscroll_content, 10)
    
local frame1 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame1, 100, 100)
DCEI.SetBackgroundImage(frame1, "frame01_blue")
    
local frame2 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImage(frame2, "frame01_brown")
    
local frame3 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame3, 100, 100)
DCEI.SetBackgroundImage(frame3, "frame01_purple")
    
local frame4 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame4, 100, 100)
DCEI.SetBackgroundImage(frame4, "frame01_grey")
    
local frame5 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame5, 100, 100)
DCEI.SetBackgroundImage(frame5, "frame01_yellow")

Related

Transform CreateVScrollFrame(Transform parent) {Transform-CreateVScrollFrameTransform-parent}

Transform CreateVScrollFrame(Transform parent)

Description

Creates a new vertically scrolling frame. This frame functions similarly to a VStack, in that it will arrange its child frames vertically, however this frame also supports vertical scrolling if the contents would be larger than the size of the scroll frame. Do not place content inside this frame directly, instead use GetScrollContent() to fetch the content frame. By default, this frame type attempts to fill its parent size unless given explicit dimensions.

Parameters

  • Transform parent the parent frame.

Example Usage

local vscroll_frame = DCEI.NewVScroll(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(vscroll_frame, "frame01")
DCEI.SetSize(vscroll_frame, 120, 350)

local vscroll_content = DCEI.GetScrollContent(vscroll_frame)
DCEI.SetSpacing(vscroll_content, 10)
DCEI.SetPadding(vscroll_content, 10)

local frame1 = DCEI.NewFrame(vscroll_content)
DCEI.SetSize(frame1, 100, 100)
DCEI.SetBackgroundImage(frame1, "frame01_blue")

local frame2 = DCEI.NewFrame(vscroll_content)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImage(frame2, "frame01_brown")

local frame3 = DCEI.NewFrame(vscroll_content)
DCEI.SetSize(frame3, 100, 100)
DCEI.SetBackgroundImage(frame3, "frame01_purple")

local frame4 = DCEI.NewFrame(vscroll_content)
DCEI.SetSize(frame4, 100, 100)
DCEI.SetBackgroundImage(frame4, "frame01_grey")

local frame5 = DCEI.NewFrame(vscroll_content)
DCEI.SetSize(frame5, 100, 100)
DCEI.SetBackgroundImage(frame5, "frame01_yellow")

Related

Transform CreateScrollFrame(Transform parent) {Transform-CreateScrollFrameTransform-parent}

Transform CreateScrollFrame(Transform parent)

Description

Creates a horizontally and vertically scrolling frame. Useful for making scrollable maps. Do not place content inside this frame directly, instead use GetScrollContent()] to fetch the content frame. By default, this frame type attempts to fill its parent size unless given explicit dimensions.

Parameters

  • Transform parent the parent frame.

Example Usage

local scroll_frame = DCEI.NewScroll(DCEI.GetUiRoot())
DCEI.SetSize(scroll_frame, 500, 500)
DCEI.SetBackgroundImageColor(scroll_frame, 1, 0, 0, 0.3)
DCEI.SetScrollInertia(scroll_frame, false)
local scroll_content = DCEI.GetScrollContent(scroll_frame)

local big_content = DCEI.NewFrame(scroll_content)
DCEI.SetSize(big_content, 1000, 1000)
DCEI.SetBackgroundImageColor(big_content, 0, 0, 1, 0.4)

local small_content = DCEI.NewFrame(scroll_content)
DCEI.SetSize(small_content, 100, 100)
DCEI.SetBackgroundImageColor(small_content, 0, 1, 0, 0.4)

Related

int GetFrameIndexInParent(Transform item) {int-GetFrameIndexInParentTransform-item}

int GetFrameIndexInParent(Transform item)

Description

Returns the given UI frame's child index in its parent UI frame. This can be useful for getting an item's position from within a stack.

Parameters

  • Transform item the UI frame to return the child index of.

Example Usage

local stack = DCEI.NewHStack(DCEI.GetUiRoot())
DCEI.SetSize(stack, 100, 100)
        
local frame1 = DCEI.NewFrame(stack)
DCEI.SetSize(frame1, 100, 100)
DCEI.SetBackgroundImageColor(frame1, 1, 0, 0, 0.4)
        
local frame2 = DCEI.NewFrame(stack)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImageColor(frame2, 1, 0, 0, 0.6)
        
local frame3 = DCEI.NewFrame(stack)
DCEI.SetSize(frame3, 100, 100)
DCEI.SetBackgroundImageColor(frame3, 1, 0, 0, 0.8)
        
local frame4 = DCEI.NewFrame(stack)
DCEI.SetSize(frame4, 100, 100)
DCEI.SetBackgroundImageColor(frame4, 0, 1, 0, 1)
        
local frame_index = DCEI.GetFrameIndexInParent(frame4)
DCEI.LogMessage("The child index of 'frame4' is: " .. frame_index)

void SetFrameIndexInParent(Transform item, int index) {void-SetFrameIndexInParentTransform-item-int-index}

void SetFrameIndexInParent(Transform item, int index)

Description

Sets the given UI frame's child index in its parent UI frame. If the new index already has a UI frame assigned to it, the frame will be inserted at the new position and its siblings indices will update to match the new order. Indices must be contiguous, trying to set a child's index to a non-contiguous index will just set it to the last contiguous index. The frame index is by default the order in which the child frames were created within the parent.

Parameters

  • Transform item the UI frame to set the child index of.
  • int index the new child index.

Example Usage

local hscroll_frame = DCEI.NewHScroll(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(hscroll_frame, "frame01")
DCEI.SetSize(hscroll_frame, 350, 120)

local hscroll_content = DCEI.GetScrollContent(hscroll_frame)
DCEI.SetSpacing(hscroll_content, 10)
DCEI.SetPadding(hscroll_content, 10)

local frame1 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame1, 100, 100)
DCEI.SetBackgroundImage(frame1, "frame01_blue")

local frame2 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame2, 100, 100)
DCEI.SetBackgroundImage(frame2, "frame01_brown")

local frame3 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame3, 100, 100)
DCEI.SetBackgroundImage(frame3, "frame01_purple")
-- This will move 'frame3' to the first index, causing it to display first
DCEI.SetFrameIndexInParent(frame3, 1)

local frame4 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame4, 100, 100)
DCEI.SetBackgroundImage(frame4, "frame01_grey")

local frame5 = DCEI.NewFrame(hscroll_content)
DCEI.SetSize(frame5, 100, 100)
DCEI.SetBackgroundImage(frame5, "frame01_yellow")

⚠️ **GitHub.com Fallback** ⚠️