Unity3d OS X Clean up player prefs / plist

23 Jun

It’s not easy to empty the Unity Player Preferences (“PlayerPrefs“) cache on OS X.

Player Preferences are kept in a plist file in ~/Library/Preferences called unity.[company name].[product name].plist

The application itself and the per user process “cfprefsd” both cache the preferences.

To be absolutely sure that the Player Properties cache is removed, follow these steps.

1. Stop the application that is using the preferences.

2. Delete the preferences:
$ defaults delete unity.somecompany.someapp

3. Delete the plist file in ~/Library/Preferences:
$ rm ~/Library/Preferences/unity.somecompany.someap.plist

4. Kill the cfprefsd process.
$ kill $(ps x | awk '/[c]fprefsd/{ print $1 }')

When next the application starts, the cache should be empty.

Thanks to Bryan (http://stackoverflow.com/users/463439/bryan) for http://stackoverflow.com/questions/19303958/deleting-plist-file-does-not-reset-app-on-mac-os-10-9-mavericks-10-10-yosemite

Unity3d Launching iOS project via Xcode4 failed

3 Jun

After upgrading Xcode, you may find that Unity is no longer able to launch the app on your iOS device via Xcode.

Although Unity is able to launch Xcode, some validation appears to fail.

The log ~/Library/Logs/Unity/Editor.log has entries like the following:

Launching Xcode
2015-06-02 13:41:22.260 Unity[14718:978416] Checking 
Waiting for Xcode plugin for up to 30 seconds
Connecting to Xcode
Disconnecting
Connecting to Xcode
Disconnecting
Connecting to Xcode
Disconnecting

[...]

Connecting to Xcode
Disconnecting
Waiting for plugin timed out
2015-06-02 13:41:52.329 Unity[14718:978416] Checking 
Connecting to Xcode
Disconnecting
Close all open unity project in Xcode failed. System.Net.Sockets.SocketException: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in :0
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in :0
  at UnityEditor.iOS.XcodeController.Connect () [0x00000] in :0
  at UnityEditor.iOS.XcodeController.RunSimpleCommand (System.String[] cmd) [0x00000] in :0
  at UnityEditor.iOS.XcodeController.RunSimpleCommand (Command cmd) [0x00000] in :0
  at UnityEditor.iOS.XcodeController.CloseAllOpenUnityProjects () [0x00000] in :0
  at UnityEditor.iOS.PostProcessiPhonePlayer.CloseUnityProjectsInXcode () [0x00000] in :0
Connecting to Xcode
Disconnecting
System.Net.Sockets.SocketException: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in :0
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in :0
  at UnityEditor.iOS.XcodeController.Connect () [0x00000] in :0
  at UnityEditor.iOS.XcodeController.OpenProject (System.String path) [0x00000] in :0
  at UnityEditor.iOS.PostProcessiPhonePlayer.LaunchInXcode (BuildTarget target, System.String path) [0x00000] in :0
UnityException: Launching iOS project via Xcode4 failed. Check editor log for details.

The problem is that an ID of the new version of Xcode is not known to Unity.  This can be corrected.

The following worked for me.

In the Finder, navigate to /Applications, right click on Xcode to get the context menu, then click in “Show Package Contents”

xcode_contextMenu_and_Applications

In the Contents directory you will see the file Info.plist
contextMenu_and_Xcode_app_and_Edit_Draft_—_WordPress_com

Double click on that file.  It will open in Xcode.

Look for the key DVTPluginCompatibilityUUID

Xcode_info_plist

Copy the value (in this case E969541F-E6F9-4D25-8158-72DC3545A6C6) with Cmd-C.

This value has now to be copied into the Unity Plugin’s Info.plist file.

Go back to the finder and navigate to /Applications/Unity, then right click on Unity.app and choose “Show Package Contents”.
contextMenu_and_Unity

Navigate to /Applications/Unity/Unity.app/Contents/PlaybackEngines/iossupport/Tools/OSX, right click on Unity4XC.xcplugin and choose “Show Package Contents”. In the “Contents” folder open Info.plist in Xcode (either double click the file or right click it and choose “Open”).

contextMenu_and_Contents_plugin

You will again land in Xcode.

Look for the key DVTPluginCompatibilityUUID again.
Click on the little “+” sign to add a new item.
Info_plist_plus_Edited

Now add the value that you found in the Xcode Info.plist file and save it with Cmd-S.
Info_plist_added_item_Edited

Close Xcode.

Clean your project in Unity.

After this modification Unity should again be able to communicate correctly with Xcode.

Many thanks to TonyE for the video at the Unity forum on which this solution is based.

Unity3d sound won’t play

13 Dec

I had created a script with a public variable taaDaa of type AudioClip. I clicked on the script in the Unity editor. The inspector showed me the public variable taaDaa so I dragged an mp3 asset over and dropped it in. Then I ran the game and …

No sound

I looked around a little and clicked on the game object to which the script is attached. In the inspector I can see the Script with its public variables, including taaDaa.

taaDaa was empty.

So I dragged the sound asset over to taaDaa and dropped it in. Then I ran the game and …

TA DAAA!

Sound at last.

You have to assign the sound asset to the public variable in the Script component attached to the game object, not to the Script object.

I hope this helps someone.

Feel free to correct me on my terminology.

Have fun with Unity sounds.

OS X pipeline command not found

5 Jan

I had this problem using bash on my MacBook with OS X. Pipes didn’t work any more. A command like

$ ls | wc

would give me the response

-bash:  wc: command not found

I thought I’d lost the wc command.  But locate found it. I checked my PATH. It was correct. Then I found that many other commands wouldn’t work. Even less didn’t work.  However, if I used the lost command without a pipe, e.g.:

$ wc *.js

then it would be found.

What was going on?

Eventually in desperation I copied the command and pasted it into a text file, then ran od on it.

$ od -bc x
0000000   154 163 040 174 302 240 167 143 012
__________ l   s       |      **   w   c  \n
0000012

And there I found the culprit.

After the vertical bar pipe symbol I expected to see octal 040, the code for a space. That’s what you see before the pipe symbol. But what I saw here was 302 followed by 240, i.e. two bytes, not one. “302 240” is a UTF-8 encoded string (C2 A0) for Unicode code point A0 and represents a non breaking space character.

The cause?

I have a German keyboard. To get a pipe symbol ‘|‘ I have to hold down the [alt]-key and press the 7-key (Shift-7 is forward-slash ‘/’). When I then typed the space after the pipe, I wasn’t letting go of the [alt]-key fast enough, so I was typing [alt]-space instead of a regular space. Bash interpreted the non-whitespace [alt]-space character as part of the command name, and couldn’t find anything to match.  If I let go of the [alt]-key before typing the space, all was well.

It turns out that you can make bash interpret the non breaking space as a regular space. Just add the following lines to ~/.inputrc:


# Map (UTF-8) non-breaking space to regular space,
# in case the user accidentally types Option-Space
# or [alt]-Space when they meant Space.
"\xC2\xA0": " "

Thanks to Xtra Crispy at https://discussions.apple.com/ for that tip.

I hope you find this before you waste as much time as I did trying to find out what was going wrong. Have fun bashing.

WordPress contact-form-7 on one.com hosted sites

7 Jan

I had a fair amount of trouble with the mail configuration of Takayuki Miyoshi‘s excellent wordpress multi language contact form plugin “Contact Form 7” (http://contactform7.com) on a one.com hosted site.

This is how I got it working.

Set up a one.com email address

One.com allows you to use any email account belonging to the domain of your one.com website for sending emails from the contact.  It does not require SMTP authentication.

First, set up the sender email account. You can do this on one.com’s Control Panel in the Mail Administration. Log in to one.com with your domain name and, if you didn’t change it, the password that one.com sent you when you set up the account.

Let’s call the email address “wp@yourdomain.com

Configure WordPress email

I installed Scott Reilly‘s “Configure SMTP” plugin in WordPress and set it up as follows

SMTP host: mailout.one.com

SMTP port: 25

SMTP Auth: not checked

SMTP e-mail: wp@yourdomain.com

All other fields are left empty / unset.

Configure contact-form-7

In your WordPress site Dashboard  click on “Form” (you should find it on the left beneath Settings) to configure a mail form.

Create a form (or use an existing one).

In the form itself there should be a field [your-email] and a field like [your-name].  Both are set by the person entering information into the form.  You’ll use these below.

Set the fields in the mail configuration box as follows:

To: formreceiver@somedomain.com

Any email account, i.e. not limited to a one.com domain, can be used as a recipient for emails from a contact form. In this case it’s “formreceiver@somedomain.com“.  Of course, you can set up an email account especially for this purpose in your own domain too as described above for the sender.

From: My Contact Form <wp@yourdomain.com>

This is the email that you set up previously.  You can change the name (in this case “My Contact Form”) to whatever you want – it can be different in each form, but the email address in the angle brackets should stay the same.

Additional Headers:

Reply-To: [your-name] <[your-email]>

This will ensure that when the receiver clicks on Reply that he will really reply to the person who entered his email address in the form and not to wp@yourdomain.com.

Ensure receivability

You may find that you can fill out a contact form and send off a mail suucessfully, but the mail doesn’t arrive in the receiver’s mailbox.  If you’ve done everything else right, then the problem is probably your spam filter.  This was certainly the case with Gmail.

Check your spam folder and mark the mails from the form mail sender (“wp@yourdomain.com“) as “not spam”.

Good luck!