Running Unity on Linux through Wine

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Editing scripts with a native Linux script editor)
(NVIDIA: Unity does not refresh windows often enough: In OpenGL mode all graphics cards are affected)
Line 402: Line 402:
 
* Graphics card: NVIDIA Geforce 9600GT/GT320M
 
* Graphics card: NVIDIA Geforce 9600GT/GT320M
 
* NVIDIA driver (proprietary) 319/331.38
 
* NVIDIA driver (proprietary) 319/331.38
* NVIDIA driver (open-source) 331.67/334.21/337.12 (These are made available when adding ppa:xorg-edgers/ppa repository)
+
* NVIDIA driver (open-source) 331.67/334.21/337.12/337.25 (These are made available when adding ppa:xorg-edgers/ppa repository)
  
 
'''Most likely culprit:'''
 
'''Most likely culprit:'''
  
NVIDIA graphics drivers, as this does not occur on Nouveau graphics drivers.
+
NVIDIA graphics drivers, although in -force-opengl mode other vendor graphics cards also experience this bug.
  
 
'''How to solve:'''
 
'''How to solve:'''
  
# Enable "Strict Draw Ordering" in PlayOnLinux's configuration of Unity. This might impact performance.
+
* Enable "Strict Draw Ordering". You have to add a key to the registry, see [[http://wiki.winehq.org/UsefulRegistryKeys UsefulRegistryKeys]]. For PlayOnLinux installation of Unity, there is an option in its configuration. This might impact performance.
  
Or
+
'''Or'''
  
# Use the Nouveau graphics driver, which does not have up to date 3D acceleration.
+
* Use the Nouveau graphics driver, which does not have up to date 3D acceleration.
  
 
==Community Support==
 
==Community Support==

Revision as of 10:05, 11 July 2014

For how to run the Unity Web Player on Linux native browsers see the Running Unity Web Player on Linux using Pipelight page.

Officially Unity Technologies only support creating executable standalone games/3D applications which can then be run on Linux, specifically Ubuntu 10.04 or newer(Source). This is done by using the Unity Editor in Microsoft Windows and OS X operating systems. Unity Technologies do not provide a Linux version of the Unity Editor. Unity Editor can still be launched on Linux by using the Windows version of the editor with mimicked Windows libraries provided by the Wine software. Stability of the editor depends on particular Linux distributions and the video/graphics cards.

Contents

Prerequisites

  • An operating system/distribution that is able to run Wine, also see 'Tested successfully on distributions' section within this wiki page.
  • PlayOnLinux - Software that is able to manage multiple versions of Wine.
  • Most recent Wine on PlayOnLinux - This is installed from within PlayOnLinux, a native installation of Wine is not required.
  • Official Windows installer file for Unity (Versions of 4.X.X are the ones tested)
  • Newest stable drivers for your graphics card

Tested successfully on following distributions

Users from the community have reported of getting Unity working on the following operating systems/distributions:

  • openSUSE 13.1 (reported to be most stable at running the Unity editor)
  • Ubuntu 12.10/13.10/14.04 and Lubuntu 13.10/14.04 (for now the only distros that receive Valve Software's support for running Steam)

Installing Unity using the terminal with a winetricks script (Experimental, yet quicker)

User "Doctor Jellyface" saw the use of PlayOnLinux as unnecessary way to install Unity, even with the better graphics interface that PlayOnLinux offers. So he created a winetricks script that installs Unity and all the necessary libraries to make Unity work on a native Wine.

1. Install Wine, by following instructions from its official website for your Linux distribution.

2. Download the newest Unity installation script from github.

3. If you have a 64 bit operating system, then it best to set the default Arch to 32 bit for new Wineprefixes as winetricks does not have much support for 64bit wineprefixes. So before proceeding with the next set, set the environment variable:

$ export WINEARCH=win32

(Example given for Ubuntu Linux)


4. Open up a terminal, move to the location of the downloaded ".verb" script and run the script using winetricks(installed by default with Wine):

$ winetricks -q "./unity3d.verb"

If this does not fully complete, remove the "-q" argument to debug.


5. A 'Unity' shortcut should be on your desktop. Wine should be launching it. If it does not then the Unity prefix should be located under "~/.local/share/wineprefixes/unity3d".

Installing PlayOnLinux

PlayOnLinux is a program that is able to manages different wine versions for cases when a Windows application works on wine version but not another and so allows easy switching without also breaking another Windows application.

Follow installation instructions provided by PlayOnLinux for your operating system/distribution.

Download Unity Installer (Windows)

Download the Windows installer of Unity from the Official Site. Do not try to run/execute the file.

Installing Wine and Unity using PlayOnLinux

Most of these numbered steps come from a user called 'Tomza', you can find his blog post on this issue on his blog for reference.

PlayOnLinux first launch

When you run PlayOnLinux for the first time, you will get the PlayOnLinux Wizard:

  • Possible first warning
PlayOnLinux cannot find wine (from Wine)

You should install it to use PlayOnLinux

The reason for this warning could be that PlayOnLinux would add the natively installed Wine as one of available Wine versions. This should cause no problems.

Click OK

  • Possible second warning
PlayOnLinux cannot find 7z (from P7ZIP full)

You should install it to use PlayOnLinux

7zip is an archive creator, extractor.

Click OK

  • Possible third warning
Windows Fonts useful for all programs you will run on PlayOnLinux

Install Windows fonts

Linux does not come with all fonts native to Windows.

Click Next

  • When all is ready

You should see:

Enjoy using PlayOnLinux

Managing wine versions

1. From PlayOnLinux's window header choose "Tools" -> "Manage Wine Versions".

2. Choose a recent 32bit Wine version, Unity 3D editor won't be 64bit until Unity 5.

Warning: Remember that the newest Wine can be unstable (Wine 1.6.2 is stable), but, at the same time, some bugs can be fixed in the recent version, and that’s why it can be the best way to go for you; fortunately, you can choose the Wine version in PlayOnLinux you like even after installing an application; the recent version is recommended for running Unity3D because of 3D driver improvements.

3. Click the arrow to install your version of Wine

Installing Unity

4. A PlayOnLinux script has been created by the Unity Community to easily install Unity. Save the following script to your disk in plain text – unity.pol. You can call it as you want, but the .pol extension should be kept so that PlayOnLinux can recognize it as its script.

#!/bin/bash

# Date : (2014-03-07 10-21 am)
# Last revision : (2014-04-10 3-12 pm)
# Wine version used : 1.7.16
# Distribution used to test : OpenSuse 13.1
# Authors : waneck-six, Damian-LinuxFan, Tomza (pogtoma@gmail.com), gnumaru
# Contributors: Goran Grncaroski (running MonoDevelop), other people (testing solutions)
# Script licence : GPL v.2
# Only For : http://www.playonlinux.com
# Depend :

# Known Issues : Asset Store window does not work at all

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Unity 3D"
PREFIX="Unity3D"
WINE_VERSION="1.7.16"

POL_SetupWindow_Init
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Unity" "http://www.unity3d.com/" "waneck-six, Damian-LinuxFan, Tomza, gnumaru" "$PREFIX"

#create prefix
export WINEARCH="win32"
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WINE_VERSION"

#setup prefix
POL_Wine_InstallFonts
POL_Call POL_Install_directx9
POL_Call POL_Install_dotnet20
POL_Call POL_Install_dotnet35
POL_Call POL_Install_dotnet40
POL_Call POL_Install_tahoma
POL_Call POL_Install_vcrun2008
POL_Call POL_Install_vcrun2010
POL_Call POL_Install_mono210
POL_Call POL_Install_d3dx9_36
POL_Call POL_Install_d3dcompiler_43
POL_Call POL_Install_dxdiag
POL_Call POL_Install_dxfullsetup
POL_Call POL_Install_physx
POL_Call POL_Install_corefonts
POL_Call POL_Install_msxml6
POL_Call POL_Install_wininet
POL_Call POL_Install_ie8

#Setting OS wer
Set_OS "winxp" "sp3"

#Setting mono forcing in MonoDevelop
POL_Wine_OverrideDLL "native, builtin" "mscore"
POL_Wine_OverrideDLL "builtin, native" "dnsapi"
POL_Wine_OverrideDLL "" "mscorsvw.exe"

mkdir -p $WINEPREFIX/drive_c/users/$USER/AppData/LocalLow

#registry
regfile=$(mktemp --suffix=.REG)
echo "REGEDIT4" > $regfile
echo "" >> $regfile
echo "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion]" >> $regfile
echo '"ProductId"="12345-oem-0000001-54321"' >> $regfile

POL_Wine regedit $regfile

POL_SetupWindow_browse "Please select the location of the Unity3D setup executable" "$TITLE"

UNITYLOC=$APP_ANSWER
POL_Wine $UNITYLOC

POL_Shortcut "Unity.exe" "$TITLE"

POL_SetupWindow_Close
exit

Note: depending on your installed wine versions edit the script and change the Wine version before running the script

For example, the script has Wine version at Wine 1.7.16, so change it to:

POL_Wine_PrefixCreate “Your.Version.Number”

Save, that’s all.

Warning for Ubuntu users: This script will fail with an due to system wide parameter called 'ptrace_scope'. See Regarding ptrace_scope fatal error for a fix.

5. From PlayOnLinux's window header choose "Tools" -> "Run a local script".

6. Choose the script that was made for automating the installation process of Unity3D and click Next.

7. You will see the warning that the signature of the script isn’t valid. Ignore it! Click Next.

8. You will be able to review your script and check if its content is OK before running. If OK, check I agree and click Next.

9. Then you will see the installation wizard, click Next, the following should appear:

The script is running

a virtual drive is being created first – it will be the place where your whole installation will be placed.

a/ The environment for the virtual disk

9. When you run PlayOnLinux for the first time, some extra software may be installed

The installation is ongoing – it isn’t too easy and you may see some errors because and probably will be forced to install some additional software in vitual disk.

After our tests, we know that to run Unity3D and MonoDevelop with no problems, we need all .NET versions installed in Wine. They are all added automatically within the script.

PlayOnLinux is installing the components it needs for Unity3D and MonoDevelop working on Wine. The list of their names is included in the script you are using. They are really important, so wait to the end of the installation patiently.

10. When the script in PlayOnLinux installs up all the components in Wine, find the Unity3D setup executable on your disk through the PlayOnLinux window.

11. Install Unity3D with using PlayOnLinux (just like under Windows). Follow the instructions you see during the Unity3D installation. You may install AngryBots project to test your installation of Unity. Among others, you need NET Framework 4.0 Extended. All will be installed automatically. Do not worry about errors too much if any – maybe they aren’t so important. PlayOnLinux can be even hang up. In such case reboot PlayOnLinux.

12. Click Finish on the Unity3D installation wizard.

When Unity3D is installed inside PlayOnLinux, you see the Unity3D icon in the main PlayOnLinux window – you can start Unity3D from here if you want.

13. You can see two Unity3D icons on your desktop. The called simply "Unity" might not work, which is installed by the Unity installer. "Unity3D" is the one created by the script.

Warning: If you reinstall Unity3D (install again on the same computer), it’s good to remove the remaining shortcut on your desktop (one of the two). One is removed automatically, but the second remains. It can make problems for making a new shortcut for a new Unity3D installation. You may do that even during Unity3D installation, but before the end of the installation because the new shortcuts are made in this time. If you don’t do that, your installation can be corrupted. You will see only one shortcut on your desktop. But this shortcut probably won’t work.

14. Do everything Unity3D wants from you (Activate your Unity License – free or pro; log in to your Unity3D account – you should have the account; if don’t, make one; then, click Start using Unity).

15. When you see the dialog (Project Wizard) for creating or opening a new project for Unity3D, you may want to open the AngryBots project if you chose to install it for testing purposes. It is located under "C:\users\Public\Documents\Unity Project\", disk "Z:" is your Linux disk.

16. Unity3D is now running.

Editing image assets with a native Linux Image Manipulation Program

By default Unity will open image files with Internet Explorer. While it is possible to set a Linux executable to be run by Unity in its preferences, the file path that Unity will provide is a Windows styled one '/PlayOnLinux Drive/C:\UnityProject\Assets' which the image manipulation program will probably not recognize.

Wine has a tool that can translate Windows styled paths to Unix styled paths. A shell script can be used as the target to translate the path before giving it to the desired program, in this case GIMP:

#!/bin/sh
if [ -z "$1" ]
then
	echo "No file specified"
	exit 1
fi

# Change 'gimp' to the command name of your desired image manipulation program.
gimp "`wine winepath -u "$1"`"
# Note that the 'wine winepath', which translates Windows path name to Unix, is the natively installed 'wine'.

echo "Opening $1 with GIMP"
exit 0

Save it to a file that Unity can see and set it as an executable(like 'chmod 755' through the terminal), then set the shell script as the Image Manipulation program in Unity Preferences.

NOTE: A native 'Wine' version needs to be installed for this script to work. TODO: Make the script use PlayOnLinux's installed Wine to translate file paths.

Editing scripts with a native Linux script editor

Depending if you installed Unity with MonoDevelop, then Unity will open script files with either Notepad or MonoDevelop by default. Same when double-clicking on script errors and warnings. While it is possible to set a Linux executable to be run by Unity in its preferences, the file path that Unity will provide is a Windows styled one '/PlayOnLinux Drive/C:\UnityProject\Assets' which the editor will probably not recognize.

Wine has a tool that can translate Windows styled paths to Unix styled paths. A shell script can be used as the target to translate the path before giving it to the desired program and also providing the line of code to jump to.

Sublime Text

#!/bin/sh
if [ -z "$1" ]
then
    echo "No file specified"
    exit 1
fi

# Change '/opt/sublime_text/sublime_text' to the path of your executable for desired IDE.
/opt/sublime_text/sublime_text "`wine winepath -u "$1"`:$2:$3"
# Note that the 'wine winepath', which translates Windows path name to Unix, is the natively installed 'wine'.

echo "Opening '$1' on line '$2' column '$3' with Sublime Text"
exit 0

Kate

#!/bin/sh
if [ -z "$1" ]
then
    echo "No file specified"
    exit 1
fi

# We assume that the kate executable is lies in '/usr/bin/'. Change the path if necessary.
/usr/bin/kate "`winepath -u "$1"`" -l "$2"
# Note that the 'wine winepath', which translates Windows path name to Unix, is the natively installed 'wine'.

echo "Opening '$1' on line '$2' with Kate"
exit 0

Save it to a file that Unity can see and set it as an executable(chmod 755), then set the shell script as the External Script Editor program in Unity Preferences with correct format in its arguments, for this shell script it's '"$(File)" $(Line)' (without the '').

NOTE: A native 'Wine' version needs to be installed for this script to work. TODO: Make the script use PlayOnLinux's installed Wine to translate file paths.

Troubleshooting

Unity Asset store does not work (Unsolved)

Reported by all that the Asset store window/tab shows up gray, but some elements on the window are picked up judging from that the mouse cursor changes. Some believe it is a WebKit issue.

WineHQ bug report - http://bugs.winehq.org/show_bug.cgi?id=34039

Project Creation: "Specified path is not valid..." error message

While it might seem strange, this is an Internet Explorer issue. It is fixed by installing Internet Explorer 8. Preferably using winetricks "ie8" or in PlayOnLinux case, "Internet Explorer 8" component.

"-force-opengl" option crashing Unity (Experimental fix)

By default Unity Editor for Windows uses Direct3D to render graphics and Wine redirects Direct3D calls to OpenGL calls, which has compatibility and performance issues. Unity Technologies have included "-force-opengl" argument to force Unity to use OpenGL.

The reason for the crash is supposedly "because Unity 3/4 does something with OpenGL contexts that is acceptable for WGL, but not for the Linux equivalent layer called GLX.". But there exists a patch for Wine that allows Unity to run in OpenGL mode, but, to add the patch, Wine has to be compiled with it included.

Performance gains are reported to be between 10% to 400%.

How to fix: If you have a 32bit Linux distribution, follow instructions in this script(note that it is for Ubuntu), you may skip the following numbered steps.

1. If you have a 64bit Linux distribution, then it should be noted that winetricks does not have full support for 64bit Wine as of yet. Follow the instructions on how to compile a 32bit Wine on a 64bit OS here, only up to the point of getting the source code.

2. Before compiling Wine, add the patch to the source code folder through the terminal:

3. Compile Wine.

4. Run Unity with the new Wine using something like

  • > env WINEPREFIX="~/.local/share/wineprefixes/unity3d" ~/wine32/wine ~/.local/share/wineprefixes/unity3d/drive_c/Program\ Files/Unity/Editor/Unity.exe -force-opengl

Results: Screenshot of a empty scene with a cube

Ubuntu: Windows cannot be fully maximized

This might actually be an issue for all Wine applications contained within a window. See the following answered question for the way in fixing this issue: http://askubuntu.com/questions/267843/how-can-i-fully-maximize-wine-applications

Unity dashboard is all grayed out

This bug may appear when the Linux system's timezone is set as a "named" timezone (like "America/Sao Paulo"). Switch the timezone to another, which is not named and has only the GMT code, like 'GMT+3'.

To do this, open up a terminal.

For Ubuntu/Debian type: sudo dpkg-reconfigure tzdata

In the menu that opens up, go down and choose "etc" and set right timezone code according to your location in GMT.

NVIDIA: Unity does not refresh windows often enough

When selecting a game object, the inspector might not refresh at the right time, showing the previous game object. Same thing may happen when writing text in a text input and seeing the previous state.

Steps to reproduce:

  1. Click on a GameObject.
  2. In inspector click on show/hide Transform tag multiple times until the line is turns up gray as if it is opened, but doesn't seem like it.
  3. When this happens, click the inspector tab(to refresh the window) and then on a parameter. When writing you should see only the previous state of the text.

Reported on:

  • Ubuntu 13.10/14.04
  • Wine 1.7.15/.16/.17/.18
  • Graphics card: NVIDIA Geforce 9600GT/GT320M
  • NVIDIA driver (proprietary) 319/331.38
  • NVIDIA driver (open-source) 331.67/334.21/337.12/337.25 (These are made available when adding ppa:xorg-edgers/ppa repository)

Most likely culprit:

NVIDIA graphics drivers, although in -force-opengl mode other vendor graphics cards also experience this bug.

How to solve:

  • Enable "Strict Draw Ordering". You have to add a key to the registry, see [UsefulRegistryKeys]. For PlayOnLinux installation of Unity, there is an option in its configuration. This might impact performance.

Or

  • Use the Nouveau graphics driver, which does not have up to date 3D acceleration.

Community Support

Unity Forum Thread

Visit and contribute in the forum thread created on the Official Unity Forum.

Wine Application Database (AppDB)

Unity Editor page - https://appdb.winehq.org/objectManager.php?sClass=application&iId=11075

If you have used the Unity Editor for notable amount of time, then it would be helpful to vote for the closest compatible test done within AppDB or make your own test.

IRC channels

Unofficial IRC channel on freenode is #unity3d-wine, since it is unofficial few to none users may be on it, don't leave it because of that.

Github repository for Wine related scripts

https://github.com/Unity3D-Wine-Support/Unity3D-on-Wine

You may also try raising your issue on official Wine related IRC channels #playonlinux or #winehq.

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox