Ejemplo n.º 1
0
        /// <summary>
        /// Called when the manager initializes in order to configure the service.
        /// </summary>
        protected virtual void LoadConfiguration()
        {
            // Attempt to load configuration from config resource if present.
            SpatialAnchorConfig config = Resources.Load <SpatialAnchorConfig>("SpatialAnchorConfig");

            if (config != null)
            {
                // Apply auth mode
                authenticationMode = config.AuthenticationMode;

                // Apply auth values
                if (string.IsNullOrWhiteSpace(spatialAnchorsAccountId))
                {
                    spatialAnchorsAccountId = config.SpatialAnchorsAccountId;
                }
                if (string.IsNullOrWhiteSpace(spatialAnchorsAccountKey))
                {
                    spatialAnchorsAccountKey = config.SpatialAnchorsAccountKey;
                }
                if (string.IsNullOrWhiteSpace(clientId))
                {
                    clientId = config.ClientId;
                }
                if (string.IsNullOrWhiteSpace(tenantId))
                {
                    tenantId = config.TenantId;
                }
            }
        }
 /// <summary>
 /// Call to apply a custom SpatialAnchorConfig to the SpatialAnchorManager
 /// </summary>
 /// <param name="config">SpatialAnchorConfig used by the created CustomSpatialAnchorManager</param>
 public void ApplyCustomConfiguration(SpatialAnchorConfig config)
 {
     if (config != null)
     {
         authenticationMode       = config.AuthenticationMode;
         spatialAnchorsAccountId  = config.SpatialAnchorsAccountId;
         spatialAnchorsAccountKey = config.SpatialAnchorsAccountKey;
         clientId = config.ClientId;
         tenantId = config.TenantId;
     }
     else
     {
         Debug.LogError("CustomSpatialAnchorManager was provided a null SpatialAnchorConfig.");
     }
 }
        /// <summary>
        /// Extension method that allows adding a CustomSpatialAnchorManager with a SpatialAnchorConfig to a GameObject
        /// </summary>
        /// <param name="gameObject">GameObject for created CustomSpatialAnchorManager</param>
        /// <param name="spatialAnchorConfig">SpatialAnchorConfig used by the created CustomSpatialAnchorManager</param>
        /// <returns></returns>
        public static SpatialAnchorManager AddCustomSpatialAnchorManager(this GameObject gameObject, SpatialAnchorConfig spatialAnchorConfig)
        {
            gameObject.SetActive(false);
            CustomSpatialAnchorManager spatialAnchorManager = gameObject.AddComponent <CustomSpatialAnchorManager>();

            spatialAnchorManager.ApplyCustomConfiguration(spatialAnchorConfig);
            gameObject.SetActive(true);
            return(spatialAnchorManager);
        }