docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License

    • Unity Live Systems Data
      • Installation
      • What's new
      • Upgrade guide
    • Get started
      • Take it further
    • Basic concepts
    • Configure your service
      • Add and configure user-supplied secrets
      • Associate 3D objects with source devices
      • Configure a facility device simulator
      • Configure data connectors
        • Device connectors
          • Azure IoT Hub device connector
          • Facility Simulator device connector
          • HTTP device connector
        • Telemetry connectors
          • Azure EventHub telemetry connector
    • Develop your application
      • Create environment settings
      • Create a services controller
      • Implement a telemetry history controller
    • Troubleshooting
    • Glossary
    • REST APIs

    Create a services controller

    The services controller works as a hub for the services within the Live Systems Data SDK package.

    Create a services controller script

    To create a services controller script, follow these steps:

    1. In your Assets/Scripts directory, create a new script and name it ServicesController.
    2. At the top of your ServicesController file, add directives to include the required namespaces.

      using Unity.DigitalTwins.Live.Sdk.Implementations;
      using Unity.DigitalTwins.Live.Sdk.Settings;
      
    3. Within the ServicesController class, add public environment settings.

      public EnvironmentSettings EnvironmentSettings;
      
    4. Add properties with public accessors and private setters for each of the Live Systems Data services you want to use. This makes each service available through the controller and handles their creation locally.

      public IConfigurationService ConfigurationService { get; private set; }
      public IFacilityService FacilityService { get; private set; }
      public ITelemetryHistoryService TelemetryHistoryService { get; private set; }
      
    5. In your Awake method, initialize the services you added earlier.

      ConfigurationService = new ConfigurationService(FacilityService);
      FacilityService = new FacilityService(EnvironmentSettings);
      TelemetryHistoryService = new TelemetryHistoryService(FacilityService);
      

    Add the services controller to your scene

    To add the services controller to your scene, follow these steps:

    1. Go to GameObject > Create Empty and rename the game object to Services.
    2. Select the Services game object you just created.
    3. In the Inspector panel, select Add Component and add the ServicesController component.
    4. Go to the ServicesController component you just added.
    5. From the Project panel, drag and drop your EnvironmentSettings into its corresponding field.
    Back to top Generated by DocFX
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023