Esempio n. 1
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            ScriptCode scriptCode = InspectedObject as ScriptCode;
            if (scriptCode == null)
                return;

            importOptions = GetImportOptions();

            isEditorField.OnChanged += x =>
            {
                importOptions.EditorScript = x;
            };

            GUIPanel textPanel = Layout.AddPanel();
            GUILayout textLayoutY = textPanel.AddLayoutY();
            textLayoutY.AddSpace(5);
            GUILayout textLayoutX = textLayoutY.AddLayoutX();
            textLayoutX.AddSpace(5);
            textLayoutX.AddElement(textLabel);
            textLayoutX.AddSpace(5);
            textLayoutY.AddSpace(5);

            GUIPanel textBgPanel = textPanel.AddPanel(1);
            textBgPanel.AddElement(textBg);

            Layout.AddElement(isEditorField);

            GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));
            reimportButton.OnClick += TriggerReimport;

            GUILayout reimportButtonLayout = Layout.AddLayoutX();
            reimportButtonLayout.AddElement(reimportButton);
            reimportButtonLayout.AddFlexibleSpace();
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieves import options for the resource we're currently inspecting.
        /// </summary>
        /// <returns>Script code import options object.</returns>
        private ScriptCodeImportOptions GetImportOptions()
        {
            ScriptCode scriptCode          = InspectedObject as ScriptCode;
            ScriptCodeImportOptions output = null;

            if (scriptCode != null)
            {
                LibraryEntry libEntry = ProjectLibrary.GetEntry(ProjectLibrary.GetPath(scriptCode));
                if (libEntry != null && libEntry.Type == LibraryEntryType.File)
                {
                    FileEntry fileEntry = (FileEntry)libEntry;
                    output = fileEntry.Options as ScriptCodeImportOptions;
                }
            }

            if (output == null)
            {
                if (importOptions == null)
                {
                    output = new ScriptCodeImportOptions();
                }
                else
                {
                    output = importOptions;
                }
            }

            return(output);
        }
Esempio n. 3
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            LoadResource();

            ScriptCode scriptCode = InspectedObject as ScriptCode;

            if (scriptCode == null)
            {
                return;
            }

            importOptions = GetImportOptions();

            isEditorField.OnChanged += x =>
            {
                importOptions.EditorScript = x;
            };

            GUIPanel  textPanel   = Layout.AddPanel();
            GUILayout textLayoutY = textPanel.AddLayoutY();

            textLayoutY.AddSpace(5);
            GUILayout textLayoutX = textLayoutY.AddLayoutX();

            textLayoutX.AddSpace(5);
            textLayoutX.AddElement(textLabel);
            textLayoutX.AddSpace(5);
            textLayoutY.AddSpace(5);

            GUIPanel textBgPanel = textPanel.AddPanel(1);

            textBgPanel.AddElement(textBg);

            Layout.AddElement(isEditorField);

            GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));

            reimportButton.OnClick += TriggerReimport;

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddElement(reimportButton);
            reimportButtonLayout.AddFlexibleSpace();
        }
Esempio n. 4
0
 private static extern void Internal_create(ScriptCodeImportOptions managedInstance);
Esempio n. 5
0
 private static extern void Internal_CreateInstance(ScriptCodeImportOptions instance);
Esempio n. 6
0
 private static extern void Internal_CreateInstance(ScriptCodeImportOptions instance);
Esempio n. 7
0
        /// <summary>
        /// Retrieves import options for the resource we're currently inspecting.
        /// </summary>
        /// <returns>Script code import options object.</returns>
        private ScriptCodeImportOptions GetImportOptions()
        {
            ScriptCode scriptCode = InspectedObject as ScriptCode;
            ScriptCodeImportOptions output = null;

            if (scriptCode != null)
            {
                LibraryEntry libEntry = ProjectLibrary.GetEntry(ProjectLibrary.GetPath(scriptCode));
                if (libEntry != null && libEntry.Type == LibraryEntryType.File)
                {
                    FileEntry fileEntry = (FileEntry)libEntry;
                    output = fileEntry.Options as ScriptCodeImportOptions;
                }
            }

            if (output == null)
            {
                if (importOptions == null)
                    output = new ScriptCodeImportOptions();
                else
                    output = importOptions;
            }

            return output;
        }
Esempio n. 8
0
        /// <summary>
        /// Starts compilation of the script files in the project for the specified assembly for the specified platform.
        /// </summary>
        /// <param name="type">Type of the assembly to compile. This determines which script files are used as input.</param>
        /// <param name="platform">Platform to compile the assemblies for.</param>
        /// <param name="debug">Determines should the assemblies contain debug information.</param>
        /// <param name="outputDir">Absolute path to the directory where to output the assemblies.</param>
        /// <returns>Compiler instance that contains the compiler process. Caller must ensure to properly dispose
        ///          of this object when done.</returns>
        public static CompilerInstance CompileAsync(ScriptAssemblyType type, PlatformType platform, bool debug, string outputDir)
        {
            LibraryEntry[] scriptEntries = ProjectLibrary.Search("*", new ResourceType[] { ResourceType.ScriptCode });

            List <string> scriptFiles = new List <string>();

            for (int i = 0; i < scriptEntries.Length; i++)
            {
                if (scriptEntries[i].Type != LibraryEntryType.File)
                {
                    continue;
                }

                FileEntry fileEntry = (FileEntry)scriptEntries[i];

                ScriptCodeImportOptions io = (ScriptCodeImportOptions)fileEntry.Options;
                if (io.EditorScript && type == ScriptAssemblyType.Editor ||
                    !io.EditorScript && type == ScriptAssemblyType.Game)
                {
                    scriptFiles.Add(Path.Combine(ProjectLibrary.ResourceFolder, scriptEntries[i].Path));
                }
            }

            string[] assemblyFolders;
            string[] assemblies;
            string   outputFile;

            string builtinAssemblyPath = debug
                    ? EditorApplication.BuiltinDebugAssemblyPath
                    : EditorApplication.BuiltinReleaseAssemblyPath;

            string[] frameworkAssemblies = BuildManager.GetFrameworkAssemblies(platform);
            if (type == ScriptAssemblyType.Game)
            {
                assemblyFolders = new string[]
                {
                    builtinAssemblyPath,
                    EditorApplication.FrameworkAssemblyPath
                };

                assemblies = new string[frameworkAssemblies.Length + 1];
                assemblies[assemblies.Length - 1] = EditorApplication.EngineAssemblyName;

                outputFile = Path.Combine(outputDir, EditorApplication.ScriptGameAssemblyName);
            }
            else
            {
                assemblyFolders = new string[]
                {
                    builtinAssemblyPath,
                    EditorApplication.FrameworkAssemblyPath,
                    EditorApplication.ScriptAssemblyPath
                };

                assemblies = new string[frameworkAssemblies.Length + 3];
                assemblies[assemblies.Length - 1] = EditorApplication.EngineAssemblyName;
                assemblies[assemblies.Length - 2] = EditorApplication.EditorAssemblyName;
                assemblies[assemblies.Length - 3] = EditorApplication.ScriptGameAssemblyName;

                outputFile = Path.Combine(outputDir, EditorApplication.ScriptEditorAssemblyName);
            }

            Array.Copy(frameworkAssemblies, assemblies, frameworkAssemblies.Length);

            string defines = BuildManager.GetDefines(platform);

            return(new CompilerInstance(scriptFiles.ToArray(), defines, assemblyFolders, assemblies, debug, outputFile));
        }
Esempio n. 9
0
        /// <summary>
        /// Starts compilation of the script files in the project for the specified assembly for the specified platform.
        /// </summary>
        /// <param name="type">Type of the assembly to compile. This determines which script files are used as input.</param>
        /// <param name="platform">Platform to compile the assemblies for.</param>
        /// <param name="debug">Determines should the assemblies contain debug information.</param>
        /// <param name="outputDir">Absolute path to the directory where to output the assemblies.</param>
        /// <returns>Compiler instance that contains the compiler process. Caller must ensure to properly dispose
        ///          of this object when done.</returns>
        public static CompilerInstance CompileAsync(ScriptAssemblyType type, PlatformType platform, bool debug, string outputDir)
        {
            LibraryEntry[] scriptEntries = ProjectLibrary.Search("*", new ResourceType[] { ResourceType.ScriptCode });

            List <string> scriptFiles = new List <string>();

            for (int i = 0; i < scriptEntries.Length; i++)
            {
                if (scriptEntries[i].Type != LibraryEntryType.File)
                {
                    continue;
                }

                FileEntry fileEntry = (FileEntry)scriptEntries[i];

                ScriptCodeImportOptions io = (ScriptCodeImportOptions)fileEntry.Options;
                if (io.EditorScript && type == ScriptAssemblyType.Editor ||
                    !io.EditorScript && type == ScriptAssemblyType.Game)
                {
                    scriptFiles.Add(Path.Combine(ProjectLibrary.ResourceFolder, scriptEntries[i].Path));
                }
            }

            string[] assemblyFolders;
            string[] assemblies;
            string   outputFile;

            string builtinAssemblyPath = debug
                    ? EditorApplication.BuiltinDebugAssemblyPath
                    : EditorApplication.BuiltinReleaseAssemblyPath;

            string[] frameworkAssemblies = BuildManager.GetFrameworkAssemblies(platform);
            var      otherAssemblies     = Directory.GetFiles(ProjectLibrary.ResourceFolder, "*.dll", SearchOption.AllDirectories).ToList(); //TODO: Make platform-agnostic.

            if (type == ScriptAssemblyType.Game)
            {
                assemblyFolders = new string[otherAssemblies.Count + 2];
                assemblies      = new string[frameworkAssemblies.Length + otherAssemblies.Count + 1];

                //TODO: Remove duplicate folders.
                {
                    int i = 0;
                    foreach (var otherAssembly in otherAssemblies)
                    {
                        assemblyFolders[i] = Path.GetDirectoryName(otherAssembly);
                        assemblies[i]      = Path.GetFileNameWithoutExtension(otherAssembly);
                        ++i;
                    }
                }
                assemblyFolders[assemblyFolders.Length - 2] = builtinAssemblyPath;
                assemblyFolders[assemblyFolders.Length - 1] = EditorApplication.FrameworkAssemblyPath;

                /*foreach (var assemblyFolder in assemblyFolders)
                 * {
                 *  //Debug.Print(assemblyFolder);
                 *  BansheeEngine.Debug.Log(assemblyFolder);
                 * }*/


                //otherAssemblies.CopyTo(assemblies, 0);
                assemblies[assemblies.Length - 1] = EditorApplication.EngineAssemblyName;

                outputFile = Path.Combine(outputDir, EditorApplication.ScriptGameAssemblyName);
            }
            else
            {
                assemblyFolders = new string[otherAssemblies.Count + 3];
                assemblies      = new string[frameworkAssemblies.Length + otherAssemblies.Count + 3];

                //TODO: Remove duplicate folders.
                {
                    int i = 0;
                    foreach (var otherAssembly in otherAssemblies)
                    {
                        assemblyFolders[i] = Path.GetDirectoryName(otherAssembly);
                        assemblies[i]      = Path.GetFileNameWithoutExtension(otherAssembly);
                        ++i;
                    }
                }
                assemblyFolders[assemblyFolders.Length - 3] = builtinAssemblyPath;
                assemblyFolders[assemblyFolders.Length - 2] = EditorApplication.FrameworkAssemblyPath;
                assemblyFolders[assemblyFolders.Length - 1] = EditorApplication.ScriptAssemblyPath;

                assemblies[assemblies.Length - 1] = EditorApplication.EngineAssemblyName;
                assemblies[assemblies.Length - 2] = EditorApplication.EditorAssemblyName;
                assemblies[assemblies.Length - 3] = EditorApplication.ScriptGameAssemblyName;

                outputFile = Path.Combine(outputDir, EditorApplication.ScriptEditorAssemblyName);
            }

            Array.Copy(frameworkAssemblies, 0, assemblies, otherAssemblies.Count, frameworkAssemblies.Length);

            string defines = BuildManager.GetDefines(platform);

            return(new CompilerInstance(scriptFiles.ToArray(), defines, assemblyFolders, assemblies, debug, outputFile));
        }