GuiBase2d

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

ไม่สามารถสร้าง
ไม่สามารถเรียกดู

GUIBase2d เป็นคลาสที่มีอยู่โดย 2D GUI Objects

สรุป

คุณสมบัติ

  • อ่านอย่างเดียว
    ไม่ซ้ำ

    อธิบายตำแหน่งหน้าจอที่เป็นไปเลยของรายการ UI ในพิกเซล

  • อ่านอย่างเดียว
    ไม่ซ้ำ

    อธิบายการหมุนเวียนหน้าจริงของ UI โดยองศา

  • อ่านอย่างเดียว
    ไม่ซ้ำ

    อธิบายขนาดหน้าจอที่เป็นไปจริงของรายการ UI

  • อ่านพร้อมๆ กัน

    เมื่อตั้งค่าเป็น true จะใช้การแปลภาษาใน GuiBase2d และลูกหลานของมัน

  • อ่านพร้อมๆ กัน

    การอ้างอิงถึง LocalizationTable ที่จะใช้ในการประยุกต์การแปลอัตโนมัติสู่ GuiBase2d และลูกหลานของมัน

  • อ่านพร้อมๆ กัน

    ปรับแต่งพฤติกรรมการเลือกแพดพักในแนวลง

  • อ่านพร้อมๆ กัน

    ปรับแต่งพฤติกรรมการเลือกแพดพานเกมในแนวโน้มทางซ้าย

  • อ่านพร้อมๆ กัน

    ปรับแต่งพฤติกรรมการเลือกแพดพักเกมในทิศทางที่ถูกต้อง

  • อ่านพร้อมๆ กัน

    ปรับแต่งพฤติกรรมการเลือกแพดพักในแนวตั้งขึ้น

  • อ่านพร้อมๆ กัน

    ช่วยให้คุณสามารถปรับแต่งการเคลื่อนไหวของแผงควบคุมเกม

อีเวนต์

  • SelectionChanged(amISelected : bool,previousSelection : GuiObject,newSelection : GuiObject):RBXScriptSignal

    เกิดขึ้นเมื่อเลือกแผงควบคุมเกมเคลื่อนไปยัง, ออกหรือเปลี่ยนแปลงใน GuiBase2d หรือ GuiObjects ต้นได้

คุณสมบัติ

AbsolutePosition

อ่านอย่างเดียว
ไม่ซ้ำ

ตําแหน่งหน้าจอของ UI เป็นสมบัติที่อ่านเท่านั้นซึ่งให้ตําแหน่งหน้าจอของ UI ในพิกเซล นี่เป็นตําแหน่งที่

เช่นเดียวกับหน้าจอ 1920 x 1080 ที่มีตำแหน่ง Frame ด้วยตำแหน่ง 0.5, 0, 0.5, 0 จะ

ตัวอย่างโค้ด

This code sample shows how a UI element's size, position and rotation can be copied without parenting a "copycat" to the original. It uses the Absolute-family of properties to orient a "copycat" Frame that covers on the screen space that the original does.

Copycat Frame

-- Place within a Frame, TextLabel, etc.
local guiObject = script.Parent
-- For this object to be rendered, it must be a descendant of a ScreenGui
local screenGui = guiObject:FindFirstAncestorOfClass("ScreenGui")
-- Create a copy
local copycat = Instance.new("Frame")
copycat.BackgroundTransparency = 0.5
copycat.BackgroundColor3 = Color3.new(0.5, 0.5, 1) -- Light blue
copycat.BorderColor3 = Color3.new(1, 1, 1) -- White
-- Orient the copy just as the original; do so "absolutely"
copycat.AnchorPoint = Vector2.new(0, 0)
copycat.Position = UDim2.new(0, guiObject.AbsolutePosition.X, 0, guiObject.AbsolutePosition.Y)
copycat.Size = UDim2.new(0, guiObject.AbsoluteSize.X, 0, guiObject.AbsoluteSize.Y)
copycat.Rotation = guiObject.AbsoluteRotation
-- Insert into ancestor ScreenGui
copycat.Parent = screenGui

AbsoluteRotation

อ่านอย่างเดียว
ไม่ซ้ำ

AbsoluteRotation เป็นสมบัติที่อ่านเท่านั้นที่อธิบายการหมุนหน้าจอเริ่มต้นของ UI ในองศา ค่านี

เช่นเดียวกับ, ถ้า FrameA มีการหมุน 40 องศา, และ FrameB ภายในมีการหมุน 50 องศา, จะเป็นเรื่องของ GuiObject.Rotation ของ FrameB จะเป็น 90 องศา.

ตัวอย่างโค้ด

This code sample shows how a UI element's size, position and rotation can be copied without parenting a "copycat" to the original. It uses the Absolute-family of properties to orient a "copycat" Frame that covers on the screen space that the original does.

Copycat Frame

-- Place within a Frame, TextLabel, etc.
local guiObject = script.Parent
-- For this object to be rendered, it must be a descendant of a ScreenGui
local screenGui = guiObject:FindFirstAncestorOfClass("ScreenGui")
-- Create a copy
local copycat = Instance.new("Frame")
copycat.BackgroundTransparency = 0.5
copycat.BackgroundColor3 = Color3.new(0.5, 0.5, 1) -- Light blue
copycat.BorderColor3 = Color3.new(1, 1, 1) -- White
-- Orient the copy just as the original; do so "absolutely"
copycat.AnchorPoint = Vector2.new(0, 0)
copycat.Position = UDim2.new(0, guiObject.AbsolutePosition.X, 0, guiObject.AbsolutePosition.Y)
copycat.Size = UDim2.new(0, guiObject.AbsoluteSize.X, 0, guiObject.AbsoluteSize.Y)
copycat.Rotation = guiObject.AbsoluteRotation
-- Insert into ancestor ScreenGui
copycat.Parent = screenGui

AbsoluteSize

อ่านอย่างเดียว
ไม่ซ้ำ

ขนาดหน้าจอของส่วนประกอบ UI ในพิกเซล สิ่งนี้เป็นตัวแทนขนาดของพิกเซลที่เอามาจากขนาดของบรรพบุรุษของมัน คุณสมบัตินี้, GuiBase2d.AbsolutePosition และ

เช่นเดียวกับหน้าจอ 1920 โดย 1080 หาก FrameA มีขนาดภายใน Frame

ตัวอย่างโค้ด

This code sample shows how a UI element's size, position and rotation can be copied without parenting a "copycat" to the original. It uses the Absolute-family of properties to orient a "copycat" Frame that covers on the screen space that the original does.

Copycat Frame

-- Place within a Frame, TextLabel, etc.
local guiObject = script.Parent
-- For this object to be rendered, it must be a descendant of a ScreenGui
local screenGui = guiObject:FindFirstAncestorOfClass("ScreenGui")
-- Create a copy
local copycat = Instance.new("Frame")
copycat.BackgroundTransparency = 0.5
copycat.BackgroundColor3 = Color3.new(0.5, 0.5, 1) -- Light blue
copycat.BorderColor3 = Color3.new(1, 1, 1) -- White
-- Orient the copy just as the original; do so "absolutely"
copycat.AnchorPoint = Vector2.new(0, 0)
copycat.Position = UDim2.new(0, guiObject.AbsolutePosition.X, 0, guiObject.AbsolutePosition.Y)
copycat.Size = UDim2.new(0, guiObject.AbsoluteSize.X, 0, guiObject.AbsoluteSize.Y)
copycat.Rotation = guiObject.AbsoluteRotation
-- Insert into ancestor ScreenGui
copycat.Parent = screenGui

AutoLocalize

อ่านพร้อมๆ กัน

เมื่อตั้งค่าเป็น true จะใช้การแปลภาษาในเวลาที่เฉพาะเจาะจง การแปลภาษานี้จะถูกประยุกต์ให้กับ GuiBase2d และลูกหลานของมัน การแปลภาษา

ดูเพิ่มเติม GuiBase2d.RootLocalizationTable .

RootLocalizationTable

อ่านพร้อมๆ กัน

การอ้างอิงถึง LocalizationTable ที่จะใช้ในการประยุกต์การแปลอัตโนมัติสู่ GuiBase2d และลูกหลานของมัน

สมบัติของ GuiBase2d.AutoLocalize ต้องถูกตั้งค่าเป็นความจริงบนตัวอุปกรณ์นี้แล

หากไม่มีคำแปลสำหรับตารางที่อ้างอิง มันจะค้นหาคำแปลในบรรพบุรุษของตารางนั้น หากมันเป็นโต๊ะการแปลและดังต่อไป

ดูเพิ่มเติม LocalizationService:GetTableEntries() ซึ่งอธิบายวิธีการใช้ GuiBase2d.RootLocalizationTable สำหรับการแปลอัตโนมัติ

SelectionBehaviorDown

อ่านพร้อมๆ กัน

ปรับแต่งพฤติกรรมการเลือกแพดพักในแนวลง

SelectionBehaviorLeft

อ่านพร้อมๆ กัน

ปรับแต่งพฤติกรรมการเลือกแพดพานเกมในแนวโน้มทางซ้าย

SelectionBehaviorRight

อ่านพร้อมๆ กัน

ปรับแต่งพฤติกรรมการเลือกแพดพักเกมในทิศทางที่ถูกต้อง

SelectionBehaviorUp

อ่านพร้อมๆ กัน

ปรับแต่งพฤติกรรมการเลือกแพดพักในแนวตั้งขึ้น

SelectionGroup

อ่านพร้อมๆ กัน

การเปิด/ปิดกลุ่มเลือกอนุญาตให้คุณเลือกได้ว่าวิธีการเลือกเกมแพดท

วิธีการ

อีเวนต์

SelectionChanged

เหตุการณ์นี้จะเกิดขึ้นเมื่อการเลือกเปลี่ยนแปลงภายในลูกหลานของ GuiBase2d ที่เชื่อมต่อ เมื่อการเลือกเน้นไปที่ GuiObject จะแสดงผลจาก GuiBase2d ทั้งหมดไปยังบรรพบุรุษของมัน และแจ้งให

พารามิเตอร์

amISelected: bool

จริงหากการเลือกใหม่ตรงกับ GuiBase2d ที่แนบมา

previousSelection: GuiObject
newSelection: GuiObject

ตัวอย่างโค้ด

This example shows how to use GuiBase2d.SelectionChanged to set the color of a background frame depending on if the gamepad selection has a child GuiObject focused in a hierarchy that looks like this:

You can add code to change the background color of backgroundWindow to green when buttons 1, 2 or 3 are selected and change to red when other buttons outside the frame are selected. This helps you to add any new buttons to the backgroundWindow without updating the code.

SelectionChanged Background Color

local backgroundWindow = script.Parent.BackgroundWindow
local function selectionChanged(isSelfSelected, previousSelection, newSelection)
if newSelection and newSelection:IsDescendantOf(backgroundWindow) then
backgroundWindow.BackgroundColor3 = Color3.new(0, 1, 0)
else
backgroundWindow.BackgroundColor3 = Color3.new(1, 0, 0)
end
end
backgroundWindow.SelectionChanged:Connect(selectionChanged)