Using C# you can simply employ #ifdef UNITY_IPHONE to hide iPhone functions when loading an iPhone project in regular Unity. But it doesn't work in JavaScript. Is there some alternative method?
While the answer "No" is strictly correct, you may find the following workaround helpful until Unity3.0 unifies the iPhone and non-iPhone versions.
In your .js file, instead of writing "#if(UNITY_IPHONE)" and "#endif" you can hide it in a multi-line comment like by writing this: "/*#if(UNITY_IPHONE)" and "#endif*/" your code will be hidden while working in your non-iphone version of the project.
After you do a fresh checkout of your project and are ready to try it in the iphone version of unity, run this python script:
import os
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
if (file[-3::] == '.js'):
filePath = os.path.join(root,file)
fileStr = open(filePath).read()
fileStr = fileStr.replace ('/*#if(UNITY_IPHONE)', '')
fileStr = fileStr.replace ('#endif*/', '')
open(filePath,'w').write(fileStr)
if ('.svn' in dirs):
dirs.remove('.svn')
Definitely not a permanent solution! It doesn't support "#else". It won't touch anything in your svn directories. Since I don't actually use a lot of javascript and just need some existing scripts to compile on both, It will hold me over until summer.
It seems like like python or bash is the right tool here; a C# editor script wouldn't be able to run until after all your unity stuff could compile, which is what this script is supposed to make happen!
No. Sorry. We'll note this down as a feature request