void Start() { synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new CSharpCompiler.ScriptBundleLoader(synchronizedInvoke); loader.logWriter = new UnityLogTextWriter(); loader.createInstance = (Type t) => { if (typeof(Component).IsAssignableFrom(t)) { return(this.gameObject.AddComponent(t)); } else { return(System.Activator.CreateInstance(t)); } }; loader.destroyInstance = (object instance) => { if (instance is Component) { Destroy(instance as Component); } }; loader.LoadAndWatchScriptsBundle(new[] { Application.streamingAssetsPath + "/BasicExampleScript.cs", Application.streamingAssetsPath + "/TestScript.cs" }); }
void Start() { synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new CSharpCompiler.ScriptBundleLoader(synchronizedInvoke); loader.logWriter = new UnityLogTextWriter(); loader.createInstance = (Type t) => { if (typeof(Component).IsAssignableFrom(t)) { return(this.gameObject.AddComponent(t)); } else { return(System.Activator.CreateInstance(t)); } }; loader.destroyInstance = (object instance) => { if (instance is Component) { Destroy(instance as Component); } }; }
void Awake() { synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new CSharpCompiler.ScriptBundleLoader(synchronizedInvoke); loader.logWriter = new UnityLogTextWriter(); }
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; }
void Start() { synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new CSharpCompiler.ScriptBundleLoader(synchronizedInvoke); loader.logWriter = new UnityLogTextWriter(); loader.createInstance = (Type t) => { if (typeof(Component).IsAssignableFrom(t)) return this.gameObject.AddComponent(t); else return System.Activator.CreateInstance(t); }; loader.destroyInstance = (object instance) => { if (instance is Component) Destroy(instance as Component); }; }
// 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; }
void OnApplicationQuit() { m_synchronizeInvoke = null; var logCallbackHandler = GameObject.FindObjectOfType <LogCallbackHandler>(); if (logCallbackHandler) { logCallbackHandler.RemoveAllCallbacks(); logCallbackHandler.enabled = false; } Debug.Log("Killing Threads"); // tell child thread to quit if (mame.mame_machine_manager.instance() != null) { mcsUnity.osd_interface_Unity osd = (mcsUnity.osd_interface_Unity)mame.mame_machine_manager.instance().osd(); if (osd != null) { lock (osd.osdlock) { osd.ScheduleExit(); } } } if (m_thread != null) { m_thread.Join(2000); } //System.Threading.Thread.Sleep(1000); Debug.Log("Exiting Main Thread."); }
public void Compile(GameObject textArea, string scriptName, GameObject attachTarget) { File.WriteAllText(Application.streamingAssetsPath + "/" + scriptName, input.text); consoleOutput.text = ""; synchronizedInvoke = new DeferredSynchronizeInvoke(); loader = new ScriptBundleLoader(synchronizedInvoke) { logWriter = new UnityLogTextWriter(), createInstance = (Type t) => { if (typeof(Component).IsAssignableFrom(t)) { string scriptToDelete = ""; switch (attachTarget.gameObject.tag) { case "Player": scriptToDelete = "GunAddOn"; break; case "Bullet": scriptToDelete = "BulletAddOn"; break; } foreach (Component component in attachTarget.GetComponents(typeof(Component))) { if (component.GetType().ToString() == scriptToDelete) { Destroy(attachTarget.GetComponent(component.GetType())); } } return(attachTarget.AddComponent(t)); } else { return(Activator.CreateInstance(t)); } }, destroyInstance = (object instance) => { if (instance is Component) { Destroy(instance as Component); } } }; try { var sourceFolder = Application.streamingAssetsPath; var files = Directory.GetFiles(sourceFolder, "*", SearchOption.AllDirectories); foreach (var file in files) { if (file.EndsWith(scriptName)) { loader.LoadAndWatchScriptsBundle(new[] { file }); } } consoleOutput.text = "Compile successful"; } catch (Exception e) { consoleOutput.text = e.ToString(); } synchronizedInvoke = new DeferredSynchronizeInvoke(); }
void Start() { Debug.Log("Unity Version: " + Application.unityVersion); Debug.Log("Platform: " + Application.platform); Debug.Log(string.Format("Application.streamingAssetsPath - '{0}'", Application.streamingAssetsPath)); Debug.Log(string.Format("Directory.GetCurrentDirectory() - '{0}'", Directory.GetCurrentDirectory())); Debug.Log(string.Format("Application.dataPath - '{0}'", Application.dataPath)); Debug.Log(string.Format("Application.persistantDataPath - '{0}'", Application.persistentDataPath)); Debug.Log(string.Format("Path.GetFullPath('.') - '{0}'", Path.GetFullPath("."))); Application.targetFrameRate = 60; m_fpsCounter = FindObjectOfType <FpsCounter>(); if (IsAndroid()) { m_win_video_window_unity = new Texture2D(400, 400, TextureFormat.RGB24, false); } else { m_win_video_window_unity = new Texture2D(400, 400, TextureFormat.ARGB32, false); } { var pixels = m_win_video_window_unity.GetPixels(); for (int i = 0; i < pixels.Length; i++) { pixels[i] = Color.magenta; } m_win_video_window_unity.SetPixels(pixels); m_win_video_window_unity.Apply(); } m_palette = new Texture2D(200, 200, TextureFormat.RGB24, false); { var pixels = m_palette.GetPixels(); for (int i = 0; i < pixels.Length; i++) { pixels[i] = Color.red; } m_palette.SetPixels(pixels); m_palette.Apply(); } m_showController = true; m_synchronizeInvoke = new DeferredSynchronizeInvoke(); for (int i = 0; i < 0xffffff + 1; i++) { m_colorCacheList.Add(new Color32()); m_colorCacheListUsed.Add(false); } }