Skip to content

Instantly share code, notes, and snippets.

@davidB
Last active August 29, 2015 13:56
Show Gist options
  • Save davidB/9246104 to your computer and use it in GitHub Desktop.
Save davidB/9246104 to your computer and use it in GitHub Desktop.

Overview

The following instruction are based on the WineHQ >... > Unity + my own experience.

What works

  • Installation,
  • scene editor and gui,
  • opening existing projects,
  • Linux export,
  • in editor play mode,
  • built-in monodevelop,
  • creating new projects,
  • the tutorial "roll-a-ball"

What does not

  • Asset store,
  • "show in explorer" menu on assets does nothing,
  • "open" menu on assets (open wine internet explorer but the opened image doesn't work, probably another issue),
  • Direct3D11 rendering (activates but shaders fallback to SM3 as when the card doesn't suppot SM5)

What was not tested

  • registering pro license and using pro features,
  • other exporters,
  • script and shader compilation,
  • importing with drag and drop from native file manager (Dolphin),
  • importing textures (including psd),
  • importing models (.fbx)
  • lots of stuff...

What was not tested with linux MonoDevelop replacement

  • editing UnityScript, Boo

Links

Installation steps

In order to make it run I had to do the following. Operation order is important, once done something inside the wine prefix - like installing .net - some tricks may not work afterwards.

  1. Pre install :

  2. Main install :

    # set a win32 wine prefix
    export WINEARCH=win32
    export WINEPREFIX=$HOME/.wine-u41
    
    # init the directory, use Windows XP (I'd got some issue with Windows version like button doesn't working)
    # you don't need to install mono or dotnet in this step (if asked)
    winecfg
    
    # install component required by unity
    # ie8 allow to create new project (I don't know why)
    # if you don't have GUIText component displayed in Unity, recheck if corefonts is installed
    winetricks tahoma d3dx9 dotnet20 dotnet40 corefonts forcemono
    
    # as suggested in comments made this directory, not sure if necessary
    mkdir -p $WINEPREFIX/drive_c/users/$USER/AppData/LocalLow
    
    # Recover a product ID from a valid windows install (XP in this case).
    # Launch regedit on Windows machine and get value under 
    # HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
    #
    # OR
    # 
    # on your fresh wine setup copy
    # from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ProductId
    # to   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
    # I didn't find how to script this task (via regedit or reg) 
    wine regedit
    
    # Normal setup (don't disable monodevelop)
    wine ~/Downloads/UnitySetup-4.3.4.exe
  3. Optionnal Post install

    # Create a script to launch unity
    cat >~/bin/unity3d <<EOF
    export WINEARCH=win32
    export WINEPREFIX=$HOME/.wine-unity3d4
    wine $WINEPREFIX/drive_c/Program\ Files/Unity/Editor/Unity.exe
    EOF
    chmod +x ~/bin/unity3d
    
    # Use Linux monodevelop (vs the unity built-in)
    # Pros : better linux integration : font display
    # Cons : can't open Unity doc from editor, may be other
    # Project should include a symlink to C: at the root
    # replacing the MonoDevelop.exe seems to work better than using External Script under Unity
    curl -o ~/bin/unity3d_monodevelopLinux.py https://gist.githubusercontent.com/davidB/9246104/raw/unity3d_monodevelopLinux.py
    chmod +x ~/bin/unity3d_monodevelopLinux.py 
    cd $WINEPREFIX/drive_c/Program\ Files/Unity/MonoDevelop/bin
    mv MonoDevelop.exe MonoDevelop.exe.orig
    ln -s ~/bin/unity3d_monodevelopLinux.py MonoDevelop.exe
    
    # workaround for the error below raised when building a project (for Linux)
    #   Error building Player: IOException: Failed to Copy File / Directory from '/Applications/Unity/Unity.app/Contents/PlaybackEngines/LinuxStandalonePlayer/Data/Resources/unity default resources' to 'Temp/StagingArea/Data/Resources/unity default resources'.
    # based on the solution of LukaKotar http://forum.unity3d.com/threads/220434-SOLUTION-Can-t-build-your-game-to-Linux
    # Usage (before build a project under unity3d):
    #  ~/bin/unity3d_workaroundMkResources.sh project/dir/path
    curl -o ~/bin/unity3d_workaroundMkResources.sh https://gist.githubusercontent.com/davidB/9246104/raw/unity3d_workaroundMkResources.sh
    chmod +x ~/bin/unity3d_workaroundMkResources.sh
    
  4. Launch Unity, register and enjoy!

    ~/bin/unity3d
#!/usr/bin/python
#encoding: utf-8
import subprocess, os, sys
#Helper function
def winepath(path):
return subprocess.check_output(['winepath', path])
#print(sys.argv)
#if len(sys.argv) < 3:
# exit(0)
#Get project file unix path
projectFilePath = winepath(sys.argv[2])
#Get project directory
projectDir = os.path.dirname(projectFilePath)
#Get project file name without directory
projectName = os.path.basename(projectFilePath)
#Get script file name
fileName = winepath(sys.argv[3])[len(projectDir) + 1:]
#Change directory
os.chdir(projectDir)
#TODO if not exist create a symlink 'C:' -> '$WINEPREFIX/drive_c' at root of the project
#Open monodevelop in current directory
subprocess.call(['monodevelop', projectName, fileName])
#! /bin/sh
#
# workaround for the error below raised when building a project (for Linux)
# Error building Player: IOException: Failed to Copy File / Directory from '/Applications/Unity/Unity.app/Contents/PlaybackEngines/LinuxStandalonePlayer/Data/Resources/unity default resources' to 'Temp/StagingArea/Data/Resources/unity default resources'.
# based on the solution of LukaKotar http://forum.unity3d.com/threads/220434-SOLUTION-Can-t-build-your-game-to-Linux
# Usage (before build a project under unity3d):
# ~/bin/unity3d_workaroundMkResources.sh project/dir/path
PRJ=$1
if [ -z "$PRJ" ] || [ ! -d $PRJ ] ; then
echo "Usage : $0 project/dir/path"
exit 1
fi
while true ; do
if [ -d $PRJ/Temp/StagingArea/Data ] && [ ! -d $PRJ/Temp/StagingArea/Data/Resources ] ; then
mkdir -p $PRJ/Temp/StagingArea/Data/Resources
echo create
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment