ReadonlyonTriggered when battery state changes.
deviceInfoSystem.onBatteryStateChanged.add((batteryState) => {
print(
"Battery state changed. New battery level: " +
batteryState.batteryLevel +
"%, isCharging: " +
batteryState.isCharging
);
});
@component
export class NewScript extends BaseScriptComponent {
onAwake() {
deviceInfoSystem.onBatteryStateChanged.add((batteryState) => {
print(
"Battery state changed. New battery level: " +
batteryState.batteryLevel +
"%, isCharging: " +
batteryState.isCharging
);
});
}
}
ReadonlyonTriggered when internet availability changed.
// @input Component.Text textObject
global.deviceInfoSystem.onInternetStatusChanged.add(function(eventData) {
script.textObject.text = eventData.isInternetAvailable
? "UPDATED: Internet is available"
: "UPDATED: No internet";
});
@component
export class NewScript extends BaseScriptComponent {
@input textObject: Text;
onAwake() {
this.textObject.text = global.deviceInfoSystem.isInternetAvailable()
? "Internet is available"
: "No internet";
global.deviceInfoSystem.onInternetStatusChanged.add((args) => {
this.textObject.text = args.isInternetAvailable
? "UPDATED: Internet is available"
: "UPDATED: No internet";
});
}
}
ReadonlyperformanceReturns the PerformanceIndexes object, which provides performance information about the device.
ReadonlyscreenSpecifies the device pixel ratio. Can be used to set rendering at the real screen resolution.
Returns the current battery state of the device.
var deviceInfoSystem = global.deviceInfoSystem;
if (!deviceInfoSystem.isEditor()) {
var batteryState = deviceInfoSystem.getBatteryState();
print(
"Current battery level: " +
batteryState.batteryLevel +
"%, isCharging: " +
batteryState.isCharging
);
}
@component
export class NewScript extends BaseScriptComponent {
onAwake() {
const deviceInfoSystem = global.deviceInfoSystem;
if (!deviceInfoSystem.isEditor()) {
const batteryState = deviceInfoSystem.getBatteryState();
print(
"Current battery level: " +
batteryState.batteryLevel +
"%, isCharging: " +
batteryState.isCharging
);
}
}
}
StaticgetGet the DeviceCamera object for the given camera ID which provides intrinsics/extrinsics of the camera.
StaticgetReturns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns the name of this object's type.
Returns whether the given texture format supports every requested capability on the current device.
usage is a combination of TextureUsage flags; all of the requested capabilities must be supported for the result to be true, and passing no flags returns false. Support depends on both the device and the graphics backend it renders with, so a format available on one device may be unavailable on another.
A format that fails the Render check cannot be used as a render target.
var deviceInfoSystem = global.deviceInfoSystem;
var format = TextureFormat.RGBA16Float;
if (deviceInfoSystem.isFormatSupported(format, TextureUsage.Render | TextureUsage.Filter)) {
print("RGBA16Float can be rendered to and filtered on this device");
} else {
print("RGBA16Float is unavailable, falling back to RGBA8Unorm");
}
Returns true if the device has access to the internet.
// @input Component.Text textObject
script.textObject.text = global.deviceInfoSystem.isInternetAvailable()
? "Internet is available"
: "No internet";
@component
export class NewScript extends BaseScriptComponent {
@input textObject: Text;
onAwake() {
this.textObject.text = global.deviceInfoSystem.isInternetAvailable()
? "Internet is available"
: "No internet";
}
}
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Provides information about the device running the Lens. Accessible through
global.deviceInfoSystem.Example