コード例 #1
0
        protected void Init()
        {
            _params = new CompilerParams();
            var ds = _params.Dependencies;

            listDependencies = new ReorderableList(ds, typeof(string));

            listDependencies.drawElementCallback += (rect, index, isActive, isFocused) =>
            {
                rect.height = 19; rect.y += 1;
                var name = System.IO.Path.GetFileName(ds[index]);
                EditorGUI.LabelField(rect, name, EditorStyles.boldLabel);
                //ds[index] = EditorGUI.TextField(rect, ds[index]);
            };

            listDependencies.drawHeaderCallback += (rect) => { GUI.Label(rect, "Additional Dependencies", EditorStyles.miniBoldLabel); };
            listDependencies.onRemoveCallback   += (list) => { ds.RemoveAt(list.index); };

            listDependencies.onAddCallback += (list) =>
            {
                var path = EditorUtility.OpenFilePanel("Add dependency", PathEditorDll, "dll");
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }
                ds.Add(path);
            };
        }
コード例 #2
0
        private void DrawPathSaveField()
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUIUtility.labelWidth = 85;
                _params.PathSave            = EditorGUILayout.TextField(new GUIContent("DLL path save"), _params.PathSave);
                EditorGUIUtility.labelWidth = 0;

                if (GUILayout.Button("Browse", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                {
                    _params.PathSave = EditorUtility.OpenFolderPanel("Add file", "", "");
                }
                if (GUILayout.Button("Reset", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                {
                    _params.PathSave = CompilerParams.GetDefaultPathSave();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
コード例 #3
0
        public static void Compiler(CompilerParams parm)
        {
            Directory.CreateDirectory(parm.PathSave);

            var opts = new Dictionary <string, string> {
                { "CompilerVersion", "v3.5" }
            };

            using (var codeProvider = new CSharpCodeProvider(opts))
            {
                var parameters = new CompilerParameters()
                {
                    GenerateExecutable = false,
                    OutputAssembly     = parm.PathSave + parm.NamePackageDll,
                };

                parameters.ReferencedAssemblies.AddRange(parm.Dependencies.ToArray());

                var phScr = parm.GetScriptsPath();
                //var codeSources = phScr.Select(f => File.ReadAllText(f)).ToList();
                //codeSources.Add(GetCodeAssemblyVersion(parm.Version));

                var result = codeProvider.CompileAssemblyFromFile(parameters, parm.GetScriptsPath().ToArray()); //FromSource(parameters, codeSources.ToArray());

                if (result.Errors.HasErrors)
                {
                    Debug.LogError("Compiler Errors!!!!!");

                    foreach (CompilerError error in result.Errors)
                    {
                        var fileName = Path.GetFileName(error.FileName);
                        Debug.LogError($"{fileName}({error.Line},{error.Column}) : {error.ErrorText}");
                    }
                }
                else
                {
                    Debug.Log("Successfully Compiled!!!!!!!!");
                }
            }
        }