public SourceCodeBundle(ScriptBundleLoader manager, IEnumerable <string> sourceCodes) { //this.manager = manager; var domain = System.AppDomain.CurrentDomain; this.assemblyReferences = domain .GetAssemblies() .Where(a => !(a is System.Reflection.Emit.AssemblyBuilder) && !string.IsNullOrEmpty(a.Location)) .Select(a => a.Location) .ToArray(); var options = new CompilerParameters(); options.GenerateExecutable = false; options.GenerateInMemory = true; options.ReferencedAssemblies.AddRange(assemblyReferences); var compiler = new CodeCompiler(); var result = compiler.CompileAssemblyFromSourceBatch(options, sourceCodes.ToArray()); foreach (var err in result.Errors) { manager.actLog(err.ToString()); } this._assembly = result.CompiledAssembly; }
public ScriptBundle(ScriptBundleLoader manager, IEnumerable <string> sources, string dllName) { DLLName = dllName; this.sources = sources; this.manager = manager; var domain = System.AppDomain.CurrentDomain; var asms = domain.GetAssemblies(); List <string> locs = new List <string> (); foreach (var asm in asms) { try { locs.Add(asm.Location); } catch { locs.Add(asm.GetName().Name); } } this.assemblyReferences = locs.ToArray(); // manager.logWriter.WriteLine ("loading " + string.Join (", ", sources.ToArray ())); CompileFiles(); }
public ScriptBundle(ScriptBundleLoader manager, IEnumerable <string> filePaths, string[] assemblyReferences) { //this.filePaths = filePaths.Select(x => Path.GetFullPath(x)); this.manager = manager; this.assemblyReferences = assemblyReferences; manager.logWriter.WriteLine("loading " + string.Join(", ", filePaths.ToArray())); CompileFiles(); CreateFileWatchers(); CreateNewInstances(); }
public IEnumerator StartEditor() { TaskManager.Instance.Init(); synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new CSharpCompiler.ScriptBundleLoader(synchronizedInvoke); loader.logWriter = new CSharpCompiler.UnityLogTextWriter(); loader.createInstance = (Type t) => { if (typeof(Component).IsAssignableFrom(t)) { Component comp = this.gameObject.AddComponent(t); ExecuteCode = true; return(comp); } else { object obj = System.Activator.CreateInstance(t); ExecuteCode = true; return(obj); } }; loader.destroyInstance = (object instance) => { if (instance is Component) { Destroy(instance as Component); } }; UpdateEditor(); // Register input keys to authorize the continued input press CustomInput.instance.RegisterKey(KeyCode.Backspace); CustomInput.instance.RegisterKey(KeyCode.LeftArrow); CustomInput.instance.RegisterKey(KeyCode.RightArrow); CustomInput.instance.RegisterKey(KeyCode.UpArrow); CustomInput.instance.RegisterKey(KeyCode.DownArrow); yield return(new WaitForSeconds(2f)); editText.text = "Press[Ctrl + E] To Launch Edit Mode"; Counter += 1; Camera.main.GetComponent <Animator>().enabled = false; }
public ScriptBundle(ScriptBundleLoader manager, IEnumerable<string> filePaths) { this.filePaths = filePaths.Select(x => Path.GetFullPath(x)); this.manager = manager; var domain = System.AppDomain.CurrentDomain; this.assemblyReferences = domain.GetAssemblies().Select(a => a.Location).ToArray(); manager.logWriter.WriteLine("loading " + string.Join(", ", filePaths.ToArray())); CompileFiles(); CreateFileWatchers(); CreateNewInstances(); }
public ScriptBundle(ScriptBundleLoader manager, IEnumerable <string> filePaths) { this.filePaths = filePaths.Select(x => Path.GetFullPath(x)); this.manager = manager; var domain = System.AppDomain.CurrentDomain; this.assemblyReferences = domain.GetAssemblies().Select(a => a.Location).ToArray(); manager.logWriter.WriteLine("loading " + string.Join(", ", filePaths.ToArray())); CompileFiles(); CreateFileWatchers(); CreateNewInstances(); }
private StreamManager() { csharpLoader = new CSharpCompiler.ScriptBundleLoader(null); csharpLoader.actLog = CSharpCompiler.UnityLogTextWriter.Log; string[] subDir = Directory.GetDirectories(Application.streamingAssetsPath); foreach (string dirname in subDir) { string infoPath = dirname + "/info.txt"; if (!File.Exists(infoPath)) { continue; } LoadMod(dirname); } }
// Start is called before the first frame update void Awake() { TaskManager.Instance.Init(); synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new CSharpCompiler.ScriptBundleLoader(synchronizedInvoke); loader.logWriter = new CSharpCompiler.UnityLogTextWriter(); loader.createInstance = (Type t) => { if (typeof(Component).IsAssignableFrom(t)) { Component comp = this.gameObject.AddComponent(t); fileComponent = comp; ExecuteFile = true; return(comp); } else { object obj = System.Activator.CreateInstance(t); ExecuteFile = true; return(obj); } }; loader.destroyInstance = (object instance) => { if (instance is Component) { Destroy(instance as Component); } }; // Copy file content to the input field string fileContent = File.ReadAllText(filePath); code = fileContent; code = code.Replace("\r", ""); Code = FormatIndenting(); Debug.Log(Code); codeUI.onValidateInput += delegate(string input, int charIndex, char addedChar) { return(OnValidateChar(addedChar)); }; Counter += 1; }
public ScriptBundleFiles(ScriptBundleLoader manager, IEnumerable <string> filePaths) { this.filePaths = filePaths.Select(x => Path.GetFullPath(x)); this.manager = manager; var domain = System.AppDomain.CurrentDomain; this.assemblyReferences = domain .GetAssemblies() .Where(a => !(a is System.Reflection.Emit.AssemblyBuilder) && !string.IsNullOrEmpty(a.Location)) .Select(a => a.Location) .ToArray(); manager.actLog("loading " + string.Join(", ", filePaths.ToArray())); CompileFiles(); //CreateFileWatchers(); //CreateNewInstances(); }