コード例 #1
0
        /// <summary>
        /// Starts a System.Process that compiles a master ink file, creating a playable JSON file that can be parsed by the Ink.Story class
        /// </summary>
        /// <param name="inkFile">Ink file.</param>
        private static void CompileInkInternal(InkFile inkFile, bool immediate)
        {
            if (inkFile == null)
            {
                Debug.LogError("Tried to compile ink file but input was null.");
                return;
            }
            if (!inkFile.isMaster)
            {
                Debug.LogWarning("Compiling InkFile which is an include. Any file created is likely to be invalid. Did you mean to call CompileInk on inkFile.master?");
            }

            // If we've not yet locked C# compilation do so now
            if (!hasLockedUnityCompilation)
            {
                hasLockedUnityCompilation = true;
                EditorApplication.LockReloadAssemblies();
            }

            InkLibrary.RemoveFromPendingCompilationStack(inkFile);
            if (InkLibrary.GetCompilationStackItem(inkFile) != null)
            {
                UnityEngine.Debug.LogWarning("Tried compiling ink file, but file is already compiling. " + inkFile.filePath);
                return;
            }

            string inputPath = InkEditorUtils.CombinePaths(inkFile.absoluteFolderPath, Path.GetFileName(inkFile.filePath));

            Debug.Assert(inkFile.absoluteFilePath == inputPath);

            CompilationStackItem pendingFile = new CompilationStackItem
            {
                inkFile              = InkLibrary.GetInkFileWithAbsolutePath(inputPath),
                inkAbsoluteFilePath  = inputPath,
                jsonAbsoluteFilePath = inkFile.absoluteJSONPath,
                state     = CompilationStackItem.State.Queued,
                immediate = immediate
            };

            InkLibrary.AddToCompilationStack(pendingFile);

            TryCompileNextFileInStack();
        }