Example #1
0
        /// <returns>An IEnvironment object which was created from AltSystem's environment that is marked as default.</returns>
        public override IEnvironment GetEnvironment()
        {
            //If the environment has been already created, just return it.
            if (_environment != null)
            {
                return(_environment);
            }

            //Get local storage to read environment code from.
            using (var localStorage = StorageClient.GetLocalStorage()) {
                if (localStorage == null)
                {
                    return(null);
                }

                //Get environment code.
                var environmentCode = localStorage.read("environment", "default");
                if (string.IsNullOrEmpty(environmentCode))
                {
                    Debug.LogError("Failed to get environment code");
                    return(null);
                }

                //Load tracking library to create environment from the code.
                using (var trackingLibrary = Library.load()) {
                    if (trackingLibrary == null)
                    {
                        Debug.LogError("Failed to load tracking library");
                        return(null);
                    }

                    //Create environment from the code.
                    _environment = trackingLibrary.createEnvironment(environmentCode);
                    if (_environment == null)
                    {
                        Debug.LogError("Failed to create environment");
                        return(null);
                    }

                    return(_environment);
                }
            }
        }
        /// <returns>The pose which was created from AltSystem's placement that is marked as default.</returns>
        protected override Pose GetPlacement()
        {
            var result = Pose.identity;

            using (var localStorage = StorageClient.GetLocalStorage()) {
                if (localStorage != null)
                {
                    var placementCode = localStorage.read("placement", "default");

                    if (string.IsNullOrEmpty(placementCode))
                    {
                        Debug.LogError("Failed to get placement code, identity pose will be used.");
                    }
                    else
                    {
                        result = _trackingLibrary.createPlacement(placementCode);
                    }
                }

                return(result);
            }
        }