October 25th, 2016
When invoking Unity from the command line it will by default not print its output to the console.
You can make it log its output to a log file by using the -logFile unityBuild.log
parameter, but if you want it to print its output instead of saving it you can simply omit the path after the -logfile
parameter:
Unity.exe -batchmode -quit -logFile
Tags: console, cout, logfile, terminal, unity, unity3d
Posted in Unity | No Comments »
July 26th, 2016
Generate SSH keys, defaults at ~/.ssh/id_rsa and id_rsa.pub
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Run Mac’s ssh-add command (not ssh-agent), adds default keys if no key is specifed, -K adds passphrases to keychain.
ssh-add -K
Create a text file called ~/.ssh/config with this content:
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
Tags: agent, keychain, mac, ssh, terminal
Posted in git, Mac | No Comments »
May 26th, 2016
First, get Homebrew if you haven’t already: http://brew.sh/
Run these commands in the terminal
brew install android-sdk
brew install android-ndk
Update Android tools by running in the terminal:
android update sdk --no-ui
Homebrew installs your Android SDK and NDK into /usr/local/Cellar/ subfolders based on which versions it installed, but luckily it also creates two symlinks that always point to the newest versions of each; /usr/local/opt/android-sdk and /usr/local/opt/android-ndk.
Lastly add those to your .bash_profile:
export ANDROID_HOME=/usr/local/opt/android-sdk
export ANDROID_NDK=/usr/local/opt/android-ndk
Tags: android, homebrew, mac, ndk, osx, SDK
Posted in Uncategorized | No Comments »
May 17th, 2016
To see only the differences between master
and branch
from when they diverged (pull request style) do
git diff master...branch #note: three dots
To see all differences between master
and branch
do
git diff master..branch #note: two dots
Note that master
or branch
can be replaced with any ref like head
depending on which branch you have checked out.
Tags: branch, command line, diverge, git, pull request, terminal
Posted in git | No Comments »
April 24th, 2016
I had a problem where flexbox didn’t wrap on iOS but worked fine on all other browsers.
Thankfully it turned out to be a simple fix, on my flexbox child item I had to change
flex: 1
to
flex: 1 0 $minWidth; // Just 'flex: 1' will break wrapping on iOS.
where $minWidth is the minimum desired width of the flexbox child item.
Tags: CSS, Flex, flex-wrap, flexbox, ios, safari, wrap
Posted in CSS, HTML | No Comments »
March 30th, 2016
To check if the mouse is over any UI element you can use
EventSystem.current.IsPointerOverGameObject()
In case that function isn’t acting to your liking and you need to debug, or if you just want to know what object is under the mouse, you can use
PointerEventData pointerData = new PointerEventData(EventSystem.current) {
position = Input.mousePosition
};
List<RaycastResult> results = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointerData, results);
results.ForEach((result) => {
Debug.Log(result);
});
Tags: IsPointerOverGameObject, mouse, RayCast, UI, unity
Posted in UI, Unity | No Comments »
October 8th, 2015
I’ve included here some first things I do after every fresh Cygwin installation.
Install Cygwin with Mintty, Zch, git, openssh, wget, curl.
Set Cygwin to use windows user home directory.
Open CygwinDir/etc/nsswitch.conf and add this line to it:
db_home: windows
Make Cygwin windows drive shortcuts shorter.
Type this into the Cygwin command line:
ln -s /cygdrive/c /c
Browse to C by typing “cd /c”. Do this for every drive you want.
Make Cygwin not fuck up file permissions
Add/modify this line to [Cygwin folder]/etc/fstab
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0
Use Mintty as terminal and Zch as shell.
Edit your cygwin shortcut to look like this:
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/zsh --login
Install Oh My Zsh in Cygwin
Just follow the normal instructions at this point:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Tags: cygwin, drive, home, user, windows
Posted in Uncategorized | No Comments »
October 6th, 2015
To stop Resharper in Visual Studio suggesting Boo.Lang when declaring List<>‘s and other types common to both libraries, simply put this script in your editor folder.
Original source: https://gist.github.com/jbevain/a982cc580fb796c93e4e
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class ReferenceRemovalProjectHook
{
static ReferenceRemovalProjectHook()
{
const string references = "\r\n <Reference Include=\"Boo.Lang\" />\r\n <Reference Include=\"UnityScript.Lang\" />";
ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
content.Replace(references, "");
}
}
Tags: Boo, C#, List, project, resharper, unity, unityvs
Posted in Unity | No Comments »
March 30th, 2015
Here’s a quick way to check if the mouse or any other coordinates are within any UI object’s boundaries.
This method doesn’t use raycast so it ignores all overlapping objects, it works just like ActionScript’s object.HitTest(coords) function.
public bool AreCoordsWithinUiObject(Vector2 coords, GameObject gameObj)
{
Vector2 localPos = gameObj.transform.InverseTransformPoint(coords);
return ((RectTransform) gameObj.transform).rect.Contains(localPos);
}
// Example usage
bool isMouseOverIcon = AreCoordsWithinGameObject(Input.mousePosition, _myUiIcon);
Tags: 2d, bounds, HitTest, mouse, rect, transform, unity
Posted in 2D, UI, Unity | 2 Comments »
January 14th, 2015
When doing 2D games in Unity it is often handy to know where the borders of the screen are in units so one can for example spawn units on the edge of the screen or detect when something leaves it.
Fortunately it’s easy to figure out when using orthographic camera.
Camera.main.orthographicSize is always half of the total screen height, with the width changing with the aspect ratio. You can get the top or bottom coordinates by adding/subtracting it to/from the camera’s y position.
For the width you can then multiply the aspect ratio with the orthographic size,
camera.orthographicSize * Screen.width/Screen.height , to get half of the total screen width.
You can then get the x position of the screen’s left border like this:
float leftSideOfScreen = Camera.main.transform.position.x - Camera.main.orthographicSize * Screen.width / Screen.height;
Tags: 2d, border, camera, orthographic, size, unity
Posted in 2D, Unity | No Comments »