Exemplo n.º 1
0
    private static void PostCompile(AscensionCompilerOperation op, ManualResetEvent evnt, string postArgs)
    {
        Process p = new Process();

        p.StartInfo.FileName  = MonoPath;
        p.StartInfo.Arguments = postArgs;

        p.EnableRaisingEvents              = true;
        p.StartInfo.CreateNoWindow         = true;
        p.StartInfo.UseShellExecute        = false;
        p.StartInfo.RedirectStandardError  = true;
        p.StartInfo.RedirectStandardOutput = true;

        p.ErrorDataReceived  += ErrorDataReceived;
        p.OutputDataReceived += OutputDataReceived;

        p.Exited += (s, ea) =>
        {
            // we are done
            evnt.Set();

            // continue
            EditorSaver.Invoke(() =>
            {
                if (p.ExitCode == 0)
                {
                    CompilationDone(op);
                }
            });
        };

        p.Start();
        p.BeginErrorReadLine();
        p.BeginOutputReadLine();
    }
Exemplo n.º 2
0
    static void RunCSharpCompiler(AscensionCompilerOperation op, ManualResetEvent evnt)
    {
#if DEBUG
        const string CMD_ARGS = "\"{0}\" -out:\"{1}\" {2} -platform:anycpu -target:library -debug+ -optimize- -warn:{3} ";
#else
        const string CMD_ARGS = "\"{0}\" -out:\"{1}\" {2} -platform:anycpu -target:library -debug- -optimize+ -warn:{3} ";
#endif

        string args = CMD_ARGS;

        if (Core.IsDebugMode)
        {
            args += "-define:DEBUG ";
        }

        if (IsUnity5)
        {
            args += "-sdk:2 ";
        }


        Process p = new Process();
        p.StartInfo.FileName  = MonoPath;
        p.StartInfo.Arguments = string.Format(args + SourceFileList, CsharpCompilerPath, AscensionUserAssemblyPath, AssemblyReferencesList, Mathf.Clamp(RuntimeSettings.Instance.compilationWarnLevel, 0, 4));

        p.EnableRaisingEvents              = true;
        p.StartInfo.CreateNoWindow         = true;
        p.StartInfo.UseShellExecute        = false;
        p.StartInfo.RedirectStandardError  = true;
        p.StartInfo.RedirectStandardOutput = true;

        p.ErrorDataReceived  += ErrorDataReceived;
        p.OutputDataReceived += OutputDataReceived;

        p.Exited += (s, ea) => {
            // we are done
            evnt.Set();

            // continue
            EditorSaver.Invoke(() => {
                if (p.ExitCode == 0)
                {
                    CompilationDone(op);
                }
            });
        };

        p.Start();
        p.BeginErrorReadLine();
        p.BeginOutputReadLine();
    }
Exemplo n.º 3
0
    public static ManualResetEvent CodeEmit()
    {
        ManualResetEvent evnt = new ManualResetEvent(false);

        try
        {
            // create path if it doesn't exist
            Directory.CreateDirectory(AscensionDataPath);

            // setup compiler options
            AscensionCompilerOperation op = new AscensionCompilerOperation();
            op.projectFilePath = ProjectFile;
            op.project         = File.Exists("Assets/__ASCENSION__/Networking/Resources/User/project.bytes")
                ? File.ReadAllBytes("Assets/__ASCENSION__/Networking/Resources/User/project.bytes").ToObject <Project>()
                : new Project();

            // network config
            op.networkFilePath      = NetworkFile;
            op.assemblyInfoFilePath = AssemblyInfoFile;

            // maps config
            op.scenesFilePath  = MapsFile;
            op.prefabsFilePath = PrefabsFile;

            // run code emitter
            AscensionCompiler.Run(op, false);

            // we are done
            evnt.Set();

            // continue
            EditorSaver.Invoke(() =>
            {
                EmissionDone(op);
            });
        }
        catch (Exception exn)
        {
            evnt.Set();
            Debug.LogException(exn);
        }

        return(evnt);
    }
Exemplo n.º 4
0
        public static void GenerateSceneObjectGuids()
        {
            if (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode ||
                EditorApplication.isCompiling || EditorApplication.isPaused || EditorApplication.isUpdating)
            {
                Debug.LogError(
                    "Can't generate scene guids while the editor is playing, paused, updating assets or compiling");
                return;
            }

            foreach (AscensionEntity en in GameObject.FindObjectsOfType <AscensionEntity>())
            {
                en.ModifySettings().SceneId = UniqueId.New();
                EditorUtility.SetDirty(en);
                EditorUtility.SetDirty(en.gameObject);
                Debug.Log(string.Format("Assigned new scene id to {0}", en));
            }

            // save scene
            EditorSaver.AskToSaveSceneAt(System.DateTime.Now.AddSeconds(1));
        }