Skip to content
This repository was archived by the owner on Sep 10, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Linux/unity3d-sublime.sh
Original file line number Diff line number Diff line change
@@ -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
46 changes: 31 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
### 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`.
135 changes: 60 additions & 75 deletions SublimeLogger-Source/LoggerImpl.cs
Original file line number Diff line number Diff line change
@@ -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++;
}
}
}
}
Binary file modified SublimeLogger.dll
Binary file not shown.
Binary file removed SublimeLogger.pdb
Binary file not shown.
28 changes: 14 additions & 14 deletions Unity.sublime-build
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
Expand Down
5 changes: 3 additions & 2 deletions UnityBuild.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"folders":
[
{
"path": "/C/Users/workstation1-user/AppData/Roaming/Sublime Text 2/Packages/UnityBuild"
"path": ".",
"name": "Unity3D Build"
}
]
],
}