Code: Another method to remove illegal filename / path chars in Unity3d
If you find yourself having to strip illegal chars from user input, as I have found myself doing on numerous occasions when dealing with files and directory paths in Unity, it is always a good idea to have a method/function handy and at the ready, there are of course many ways to do this and I know that some would lean towards Regex as I have also done in the past, but here’s my adapted unity 3d – c# .net offering that also does what it says on the tin.
public static string RemoveInvalidFilenameCharacters
(string filename
) {
int i
;
if (!string.IsNullOrEmpty(filename
)) {
List
<char> invalidchars
=new List
<char>();
invalidchars
.AddRange("\"#%&*/:<>?\\{|}~".ToCharArray());
invalidchars
.AddRange(System.IO.Path.GetInvalidPathChars());
invalidchars
.AddRange(System.IO.Path.GetInvalidFileNameChars());
invalidchars
.AddRange(new char[]{System.IO.Path.PathSeparator,
System.IO.Path.AltDirectorySeparatorChar});
for(i
=0;i
<invalidchars
.Count;++i
) {
filename
= filename
.Replace(invalidchars
[i
].ToString(),
string.Empty);
}
}
return filename
;
}
Code: Using an Unity Editor Script to handle your build and Pre/Post Build functions
PostprocessBuildPlayer scripts do not fire on windows machines to date, and a pre process script for unity does not exist in the public domain, so here is an editor script which adds two custom buttons to your menu:- Custom Build, and Custom Build-Run. The purpose of this script is to allow you to handle any file copying or amendment to the build folder pre or post build automatically.
The script takes all the information required from the normal build window options into account, when executed manually it allows the user to choose a save path, it then fires a pre-process function before building and post process function after building and the build path is sent as a parameter, from within these functions you can call whatever you heart desires from c# file copying code to calling other applications and sending parameters alongside
Read More…
Lab: Full application functionality from Unity3d at runtime standalone

Although my runtime library hasn’t been updated officially for sometime now, here’s a good showcase of how it has come on and the reason it was created in the first place.
Yesterday was the first official release of the free application SPACE (Simulated Performing Arts Creative Environment) built upon the backbone of the runtime library allowing unity pro users to create runtime applications easily and without the major headaches involved in coding such a thing, all coded in native unity3d (no DLL’s).
Although this version of the fusedworks SPACE application is curently only PC standalone, MAC release later next week, it shows how versatile a 3d engine such as Unity3d can be.
Here’s the official link:-
http://www.space.fusedworks.com/?page_id=203
Code: Converting from all standard systems to Unity3d's Yup Left Handed.
In 3D, we have a total of 48 different combinations of space coordinates to choose from:-
2 handed (or single axis flipped) systems x 3 axis x 4 (90 degree possible rotations around each (generally)) x 2 (possible 2 flipped axis variations on the same hand same rotation) = 48 possibilities.
There are 6 ways to notate xyz in a file but this would essentially replicate one of the 48 possibilities simply converting it from one possibility to another.
The functions below will only cover converting the 6 basic types (2 handed (or single axis flipped) systems x 3 axis) to Y-Up Left Hand system used by unity, so discounting the one that unity uses equals five conversions & one non conversion, also presuming all notation is written x,y,z irrespective of direction.
Read More…