/// <summary> /// Does the compilation of the script into an assembly. /// If it was not compiled before or is dirty, it is compiled first. /// From the compiled assembly, a new instance of the newly created script class is created /// and stored in m_ScriptObject. /// </summary> /// <returns>True if successfully compiles, otherwise false.</returns> public virtual bool Compile() { this.m_WasTriedToCompile = true; if (_compilerResult != null) { return(true); } _compilerResult = ScriptCompilerService.Compile(new string[] { ScriptText }, out m_Errors); bool bSucceeded = (null != _compilerResult); if (_compilerResult != null) { this.m_ScriptObject = null; try { this.m_ScriptObject = _compilerResult.ScriptAssembly.CreateInstance(this.ScriptObjectType); if (null == m_ScriptObject) { bSucceeded = false; m_Errors = new string[1]; m_Errors[0] = string.Format("Unable to create scripting object (expected type: {0}), please verify namespace and class name!\n", this.ScriptObjectType); } } catch (Exception ex) { bSucceeded = false; m_Errors = new string[1]; m_Errors[0] = string.Format("Exception during creation of scripting object: {0}\n", ex.Message); } } return(bSucceeded); }
/// <summary> /// Does the compilation of the script into an assembly. /// If it was not compiled before or is dirty, it is compiled first. /// From the compiled assembly, a new instance of the newly created script class is created /// and stored in m_ScriptObject. /// </summary> /// <returns>True if successfully compiles, otherwise false.</returns> public virtual bool Compile() { _wasTriedToCompile = true; if (_compilerResult != null) { return(true); } var scriptCompilerResult = ScriptCompilerService.Compile(new string[] { ScriptText }); return(SetCompilerResult(scriptCompilerResult)); }