diff --git a/Linux/unity3d-sublime.sh b/Linux/unity3d-sublime.sh new file mode 100755 index 0000000..aac29bd --- /dev/null +++ b/Linux/unity3d-sublime.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +LOCA="$1" + +subl "${LOCA}" +echo "LOCA=${LOCA}" +echo "Opening '$1' on line '$2' column '$3' with Sublime Text" +exit 0 diff --git a/README.md b/README.md index 86932fd..2530814 100755 --- a/README.md +++ b/README.md @@ -1,24 +1,40 @@ -UnityBuild -======== +# Unity3D Build -This is an extension of Sublime Text 2 to support Unity 3d builds. +This is a Sublime Text 3 package to support Unity3D builds. +This is a fork of https://github.com/fredpointzero/UnityBuild as the original project is no longer maintained. -Use Unity as build system and enjoy ! +Tested with: +* Windows 7 +* Unity 5.3.2p2 +* Sublime Text 3 Build 3103 -Windows -======== +The logger used is based on Jacob Pennock's logger +* [Blog](http://www.jacobpennock.com/Blog/using-sublime-text-2-with-unity3d-2/) +* [Unity3D Forum](http://forum.unity3d.com/threads/using-unity-with-sublime-text-2-how-to-get-everything-set-up.128352/) -If it does not work at the first time, check the xbuild path in UnityBuild.sublime-build (it uses the default location of Unity) -(C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\bin\\) +## How to install -OSX -======== +Clone this repo into `Sublime Text 3/Packages/Unity3DBuild`. -Make sure you have MonoDevelop 2.10.2 installed on your OSX in the default location. -If get it here : http://download.mono-project.com/archive/2.10.2/macos-10-x86/5.4/MonoFramework-MRE-2.10.2_5.4.macos10.novell.x86.dmg +## Usage -If it does not work at the first time, check the xbuild path in UnityBuild.sublime-build (it uses the default location of Unity) -(/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Commands/xbuild) +1. Create a ST3 project exactly named like the Unity3D project. +2. Select the build system `Tools -> Build System -> Unity` +Hint: You ST3 project file must have the same name as your project's `.sln` file -NB : The logger used is based on Jacob Pennock's logger \ No newline at end of file +### Windows + +* `F7` starts the build. +* `Ctr+Shift+B` lets you select a between `build` and `clean` +* `F4` jumps to the next error or warning +* `Shift+F4` jumps to the previous error or warning + +### OSX + +TODO! + +## How To Build + +1. Build the Sublime Logger `.dll` from source. +2. Copy the `.dll` next to the `.sublime-build`. diff --git a/SublimeLogger-Source/LoggerImpl.cs b/SublimeLogger-Source/LoggerImpl.cs index 3ca920e..d4a80de 100755 --- a/SublimeLogger-Source/LoggerImpl.cs +++ b/SublimeLogger-Source/LoggerImpl.cs @@ -1,75 +1,60 @@ -using System; -using System.Diagnostics; -using System.IO; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; - -namespace SublimeLogger -{ - public class LoggerImpl : Logger - { - private int ErrorCount; - private int WarningCount; - private string ProjectDirectory; - - - public override void Initialize(IEventSource eventSource) - { - eventSource.ProjectStarted += ProjectStarted; - eventSource.BuildStarted += BuildStarted; - eventSource.BuildFinished += BuildFinished; - eventSource.ErrorRaised += ErrorRaised; - eventSource.WarningRaised += WarningRaised; - ErrorCount = 0; - WarningCount = 0; - } - - void ProjectStarted(object sender, ProjectStartedEventArgs e) - { - ProjectDirectory = Path.GetDirectoryName(e.ProjectFile); - } - - void BuildFinished(object sender, BuildFinishedEventArgs e) - { - Console.ForegroundColor = ConsoleColor.White; - if (e.Succeeded) - { - Console.ForegroundColor = ConsoleColor.DarkGreen; - Console.WriteLine("Compilation SUCCEEDED! Errors:{0} Warnings:{1}",ErrorCount,WarningCount); - } - else - { - Console.ForegroundColor = ConsoleColor.DarkRed; - Console.WriteLine("Compilation FAILED! Errors:{0} Warnings:{1}",ErrorCount,WarningCount); - } - Console.BackgroundColor = ConsoleColor.Black; - } - - void BuildStarted(object sender, BuildStartedEventArgs e) - { - Console.WriteLine("Sublime Text 2 output logger by Jacob Pennock, Updated by Frédéric Vauchelles"); - } - - void ErrorRaised(object sender, BuildErrorEventArgs e) - { - string fullPath = ProjectDirectory != null ? Path.Combine(ProjectDirectory, e.File) : e.File; - Console.ForegroundColor = ConsoleColor.DarkRed; - Console.WriteLine("{0}({1},{2}) error:{3} {4}", fullPath, e.LineNumber, e.ColumnNumber, e.Code, e.Message); - ErrorCount++; - Console.ForegroundColor = ConsoleColor.White; - } - - void WarningRaised(object sender, BuildWarningEventArgs e) - { - string fullPath = ProjectDirectory != null ? Path.Combine(ProjectDirectory, e.File) : e.File; - Console.ForegroundColor = ConsoleColor.DarkYellow; - if (e.Code != null) - { - Console.WriteLine("{0}({1},{2}) warning:{3} {4}", fullPath, e.LineNumber, e.ColumnNumber, e.Code, e.Message); - WarningCount++; - } - Console.ForegroundColor = ConsoleColor.White; - } - - } -} +using System; +using System.Diagnostics; +using System.IO; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace SublimeLogger +{ + public class LoggerImpl : Logger + { + private int m_errorCount; + private string m_projectDirectory; + private int m_warningCount; + + public override void Initialize(IEventSource eventSource) + { + Debug.Assert(eventSource != null, "eventSource != null"); + eventSource.ProjectStarted += HandleProjectStarted; + eventSource.BuildFinished += HandleBuildFinished; + eventSource.ErrorRaised += HandleErrorRaised; + eventSource.WarningRaised += HandleWarningRaised; + m_errorCount = 0; + m_warningCount = 0; + } + + private void HandleProjectStarted(object sender, ProjectStartedEventArgs e) + { + m_projectDirectory = Path.GetDirectoryName(e.ProjectFile); + } + + private void HandleBuildFinished(object sender, BuildFinishedEventArgs e) + { + if (e.Succeeded) + { + Console.WriteLine("Build succeeded. Warnings:{0}", m_warningCount); + } + else + { + Console.WriteLine("Build failed. Errors:{0} Warnings:{1}", m_errorCount, m_warningCount); + } + } + + private void HandleErrorRaised(object sender, BuildErrorEventArgs e) + { + var fullPath = m_projectDirectory != null ? Path.Combine(m_projectDirectory, e.File) : e.File; + Console.WriteLine("{0}:{1}:{2}: Error: {3}", fullPath, e.LineNumber, e.ColumnNumber, e.Message); + m_errorCount++; + } + + private void HandleWarningRaised(object sender, BuildWarningEventArgs e) + { + var fullPath = m_projectDirectory != null ? Path.Combine(m_projectDirectory, e.File) : e.File; + if (e.Code != null) + { + Console.WriteLine("{0}:{1}:{2}: Warning: {3}", fullPath, e.LineNumber, e.ColumnNumber, e.Message); + m_warningCount++; + } + } + } +} diff --git a/SublimeLogger.dll b/SublimeLogger.dll index cf49856..c46cacf 100755 Binary files a/SublimeLogger.dll and b/SublimeLogger.dll differ diff --git a/SublimeLogger.pdb b/SublimeLogger.pdb deleted file mode 100755 index a095b7c..0000000 Binary files a/SublimeLogger.pdb and /dev/null differ diff --git a/Unity.sublime-build b/Unity.sublime-build index 64c4327..7efdd01 100755 --- a/Unity.sublime-build +++ b/Unity.sublime-build @@ -1,41 +1,41 @@ { "windows": { "cmd": [ - "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\bin\\xbuild.bat", - "${project_path}\\\\${project_base_name}-csharp.sln", + "C:\\Program Files\\Unity\\Editor\\Data\\Mono\\bin\\xbuild.bat", + "${project_path}\\\\${project_base_name}.sln", "/noconsolelogger", - "/logger:${packages}\\Unity3D Build System\\SublimeLogger.dll" + "/logger:${packages}\\Unity3DBuild\\SublimeLogger.dll" ], - "file_regex": "^([\\d\\w:\\\\\\.-]*)\\((\\d+),(\\d+)\\)\\s*(.*)$" + "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", }, "osx": { "cmd": [ - "/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Commands/xbuild", - "${project_path}/${project_base_name}-csharp.sln", + "/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/bin/xbuild", + "${project_path}/${project_base_name}.sln", "/noconsolelogger", - "/logger:${packages}/Unity3D Build System/SublimeLogger.dll" + "/logger:${packages}/Unity3DBuild/SublimeLogger.dll" ], - "file_regex": "^([\\d\\w:/\\.-]*)\\((\\d+),(\\d+)\\)\\s*(.*)$" + "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", }, "variants": [ { "name": "Clean", "windows": { "cmd": [ - "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\bin\\xbuild.bat", - "${project_path}\\\\${project_base_name}-csharp.sln", + "C:\\Program Files\\Unity\\Editor\\Data\\Mono\\bin\\xbuild.bat", + "${project_path}\\\\${project_base_name}.sln", "/target:Clean", "/noconsolelogger", - "/logger:${packages}\\Unity3D Build System\\SublimeLogger.dll" + "/logger:${packages}\\Unity3DBuild\\SublimeLogger.dll" ] }, "osx": { "cmd": [ - "/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Commands/xbuild", - "${project_path}/${project_base_name}-csharp.sln", + "/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/bin/xbuild", + "${project_path}/${project_base_name}.sln", "/target:Clean", "/noconsolelogger", - "/logger:${packages}/Unity3D Build System/SublimeLogger.dll" + "/logger:${packages}/Unity3DBuild/SublimeLogger.dll" ] } } diff --git a/UnityBuild.sublime-project b/UnityBuild.sublime-project index b88efe1..cfaf1bf 100755 --- a/UnityBuild.sublime-project +++ b/UnityBuild.sublime-project @@ -2,7 +2,8 @@ "folders": [ { - "path": "/C/Users/workstation1-user/AppData/Roaming/Sublime Text 2/Packages/UnityBuild" + "path": ".", + "name": "Unity3D Build" } - ] + ], }