Preparing search index...

    Class DeviceInfoSystem

    Provides information about the device running the Lens. Accessible through global.deviceInfoSystem.

    var osType = global.deviceInfoSystem.getOS();
    var isMobile = (osType == OS.iOS || osType == OS.Android);

    Hierarchy (View Summary)

    Index

    Properties

    onBatteryStateChanged: event1<BatteryStateArgs, void>

    Triggered when battery state changes.

    Lens Scripting Version 364

    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
    );
    });
    }
    }
    onInternetStatusChanged: event1<InternetStatusChangedArgs, void>

    Triggered when internet availability changed.

    Lens Scripting Version 301

    // @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";
    });
    }
    }
    performanceIndexes: PerformanceIndexes

    Returns the PerformanceIndexes object, which provides performance information about the device.

    Lens Scripting Version 323

    screenScale: number

    Specifies the device pixel ratio. Can be used to set rendering at the real screen resolution.

    Lens Scripting Version 271

    Methods

    • Returns the current battery state of the device.

      Returns BatteryStateArgs

      Lens Scripting Version 364

      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
      );
      }
      }
      }
    • Returns the version of the LensCore library.

      Returns number

      Lens Scripting Version 364

    • Exposes User Data

      Returns the operating system type of the device.

      Returns OS

    • Get the DeviceCamera object for the given camera ID which provides intrinsics/extrinsics of the camera.

      Parameters

      Returns DeviceCamera

    • Returns 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 string

    • Returns whether the current Lens is running in CameraKit.

      Returns boolean

      Lens Scripting Version 303

    • Returns whether the current Lens is running in a desktop computer.

      Returns boolean

      Lens Scripting Version 148

    • Returns whether the current Lens is running in Lens Studio.

      Returns boolean

      Lens Scripting Version 148

    • 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.

      Parameters

      Returns boolean

      Lens Scripting Version 375

      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.

      Returns boolean

      Lens Scripting Version 300

      // @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 whether the current Lens is running in a mobile device.

      Returns boolean

      Lens Scripting Version 148

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Returns whether the current Lens is running in a Spectacles device.

      Returns boolean

      Lens Scripting Version 148

    • Accepts a callback which indicates whether the current device is capable of providing both front and rear camera texture simultaneously.

      Parameters

      • callback: (supportsDualCamera: boolean) => void

      Returns void

      Lens Scripting Version 301