Breakroom is now Sinewave Campus. Book a meeting

SLayerMask

العميلالأنواع
في هذا الصنفSetLayers
  1. الدوال
  2. SetLayers
  3. AddLayer
  4. RemoveLayer
  5. New
  6. الخصائص
  7. Inverted
  8. Layers
الأعضاء 6
دالةSetLayers_Function that changes an existing layer mask _
دالةAddLayerAdd a new layer to an existing layer mask.
دالةRemoveLayerRemove a new layer from an existing layer mask.
دالةNewStatic function that creates a new layer mask
خاصيةInvertedIs the mask exclusionary or not.
خاصيةLayersThe layer names represented in this layer mask

الدوال​

SetLayers​

void SetLayers(params string[] layerNames)
void SetLayers(Table layerNames)

_Function that changes an existing layer mask _

المعاملات

الاسمالنوعالقيمة الافتراضية
layerNamesparams string[]–
layerNamesTable–

القيم المرجعة

void

مثال

Lua
-- Let's create a new layer mask to filter out other avatars, then overwrite it to be vehicles instead:
local mask = LayerMask.New({"Avatars"});
mask.SetLayers({"Vehicles"});
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
Lua
-- Let's create a new layer mask to filter out other avatars, then overwrite it to be vehicles instead:
local mask = LayerMask.New("Avatars");
mask.SetLayers("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)

AddLayer​

void AddLayer(string layerName)

Add a new layer to an existing layer mask.

المعاملات

الاسمالنوعالقيمة الافتراضية
layerNamestring–

القيم المرجعة

void

مثال

Lua
local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
Lua
local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)

RemoveLayer​

void RemoveLayer(string layerName)

Remove a new layer from an existing layer mask.

المعاملات

الاسمالنوعالقيمة الافتراضية
layerNamestring–

القيم المرجعة

void

مثال

Lua
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
Lua
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)

New​

static SLayerMask New(Table layerNames)
static SLayerMask New(params string[] layerNames)

Static function that creates a new layer mask

المعاملات

الاسمالنوعالقيمة الافتراضية
layerNamesTable–
layerNamesparams string[]–

القيم المرجعة

SLayerMask

مثال

Lua
local mask = LayerMask.New({"Avatars", "Vehicles"});
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
Lua
local mask = LayerMask.New("Avatars");
or
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)

الخصائص​

Inverted​

bool Inverted {get; set; }

Is the mask exclusionary or not.

مثال

Lua
local mask = LayerMask.New("Avatars");
-- Now change it to be an exclusionary mask that gets everything EXCEPT Avatars.'

mask.inverted = true;

Layers​

string[] Layers {get; set; }

The layer names represented in this layer mask

مثال

Lua
local mask = LayerMask.New("Avatars");
-- Get
local layers = mask.Layers;
-- Set
local layers = {"Vehicles", "UI"};

mask.Layers = layers;