示例#1
0
        /// <summary>
        /// Parses the <paramref name="plist"/> and constructs a new <see cref="ARObjectInfo"/>.
        /// </summary>
        /// <param name="plist">A valid <c>PlistDocument</c> to parse.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="plist"/> is <c>null</c>.</exception>
        public ARObjectInfo(XmlDocument plist)
        {
            if (plist == null)
            {
                throw new ArgumentNullException(nameof(plist));
            }

            // Parse the plist
            var root = new Plist(plist).root;

            version = root["Version"].AsInt32() ?? 0;
            trackingDataReference = root["TrackingDataReference"].AsString() ?? "";
            imageReference        = root["ImageReference"].AsString() ?? "";
            var dict = root["ReferenceOrigin"];

            if (dict != null)
            {
                var rotation    = FlipHandedness(dict["rotation"].AsQuaternion() ?? Quaternion.identity);
                var translation = FlipHandedness(dict["translation"].AsVector3() ?? Vector3.zero);
                referenceOrigin = new Pose(translation, rotation);
            }
            else
            {
                referenceOrigin = Pose.identity;
            }
        }
        public static string Compile(string assetCatalogPath, string outputDirectory, Version minimumDeploymentTarget)
        {
            try
            {
                var(stdout, stderr, exitCode) = Cli.Execute($"xcrun", new[]
                {
                    "actool",
                    $"\"{assetCatalogPath}\"",
                    $"--compile \"{outputDirectory}\"",
                    "--platform iphoneos",
                    $"--minimum-deployment-target {minimumDeploymentTarget}",
                    "--warnings",
                    "--errors"
                });

                if (exitCode != 0)
                {
                    throw new ExecutionFailedException(exitCode, stderr);
                }

                // Parse the plist
                var plist       = Plist.ReadFromString(stdout);
                var outputFiles = plist.root?["com.apple.actool.compilation-results"]?["output-files"]?.AsArray();
                if (outputFiles?.Length < 1)
                {
                    throw new CompilationFailedException();
                }

                return(outputFiles[0].AsString());
            }
            catch (Win32Exception e)
            {
                throw new XCRunNotFoundException(e);
            }
        }