OpacityComponent
A component that controls the opacity of an entity and its descendants.
Declaration
struct OpacityComponentMentioned in
Overview
An opacity component multiplies its opacity property with all visual components the entity and its descendants own. Visual components include ModelComponent and ParticleEmitterComponent. If a descendant also has its own opacity component, the system combines the two opacities by multiplying their values. The system repeats this pattern for the entity’s entire family tree.
For example, the following code sets a component’s opacity value to 0.5 for its entity:
// Load a USDZ model from a file, or create a model component.
let robot = try await Entity(named: "vintage_robot")
// Create an opacity component.
let opacityComponent = OpacityComponent(opacity: 0.5)
// Apply the opacity component to the robot entity.
robot.components.set(opacityComponent)The following images show robot models with opacity values of 1.0 and 0.5.
|
|
|---|---|
[Image] | [Image] |