Exemple #1
0
 public AnchoringService(string name, uint priority, BaseMixedRealityProfile profile) :
     base(name, priority, profile)
 {
     _defaultProfile = profile as AnchoringServiceProfile;
     if (_defaultProfile == null)
     {
         _defaultProfile = ScriptableObject.CreateInstance <AnchoringServiceProfile>();
     }
     _verboseLogging = _defaultProfile.VerboseLogging;
 }
        /// <summary>
        /// Attempt to load the profile from the Override File Path.
        /// </summary>
        /// <param name="fallback">The fallback data to use if no file is found.</param>
        /// <returns>The loaded configuration</returns>
        public static async Task <AnchoringServiceProfile> Load(AnchoringServiceProfile fallback = null)
        {
            ServiceConfigurationFile file = new ServiceConfigurationFile();

            // load in the installed file
            ServiceConfigurationFile.FileData fileData = await file.LoadMerged();

            fallback = CreateProfile(fileData, fallback);

            return(fallback);
        }
        /// <summary>
        /// Create a profile from the given file data, or using the fallback data.
        /// </summary>
        private static AnchoringServiceProfile CreateProfile(ServiceConfigurationFile.FileData fileData, AnchoringServiceProfile fallback)
        {
            AnchoringServiceProfile result;

            if (fallback == null)
            {
                result = ScriptableObject.CreateInstance <AnchoringServiceProfile>();
            }
            else
            {
                result = Object.Instantiate(fallback);
            }

            if (fileData == null)
            {
                return(result);
            }

            var anchorSettings = fileData.Anchor;

            if (anchorSettings != null)
            {
                if (anchorSettings.ShouldSerializeAnchorAccountId() &&
                    anchorSettings.ShouldSerializeAnchorAccountKey())
                {
                    result.AnchorAccountId  = anchorSettings.AnchorAccountId;
                    result.AnchorAccountKey = anchorSettings.AnchorAccountKey;
                }
            }

            return(result);
        }