public static CompileUnit[] Convert(ICompilerInput input)
 {
     var converter = new UnityScriptConverter();
     converter.Input.Add(input);
     converter.References.Add(typeof (UnityEngine.MonoBehaviour).Assembly);
     converter.References.Add(typeof (ExampleScript).Assembly);
     return converter.Run();
 }
Example #2
0
        public static CompileUnit[] convert(string fileName, string[] references)
        {
            UnityScriptConverter unityScriptConverter = new UnityScriptConverter();
            unityScriptConverter.Input.Add(new FileInput(fileName));
            foreach (string current in references)
                unityScriptConverter.AddReference(current);

            return unityScriptConverter.Run();
        }
Example #3
0
        public static CompileUnit[] Convert(ICompilerInput input)
        {
            var converter = new UnityScriptConverter();

            converter.Input.Add(input);
            converter.References.Add(typeof(UnityEngine.MonoBehaviour).Assembly);
            converter.References.Add(typeof(ExampleScript).Assembly);
            return(converter.Run());
        }
Example #4
0
        public static string ExamleHtmlFor(string inputjavascript)
        {
            var sb = new StringBuilder();

            sb.Append("<p>");
            sb.Append("<p>Javascript:<br>");
            var converter = new UnityScriptConverter();

            var javascript = RemoveGlobalIndenting(inputjavascript).Trim();

            sb.AppendFormat(@"<div class='example'><pre>{0}</pre></div>", javascript);

            converter.Input.Add(new StringInput("example", javascript));
            converter.References.Add(typeof(UnityEngine.MonoBehaviour).Assembly);
            converter.References.Add(typeof(UnityEditor.MenuItem).Assembly);

            CompileUnit[] covertedCode = null;
            try
            {
                covertedCode = converter.Run();
            }
            catch
            {
                return(sb.ToString());
            }

            var csharp = new StringWriter();

            covertedCode[0].Accept(new CSharpPrinter(csharp));

            sb.Append("<p>C#<br>");
            sb.AppendFormat(@"<div class='example'><pre>{0}</pre></div>", csharp);

            sb.Append("<p>Boo<br>");
            sb.AppendFormat(@"<div class='example'><pre>{0}</pre></div>", covertedCode[1].ToCodeString());
            return(sb.ToString());
        }