Created
October 23, 2018 13:34
-
-
Save v01pe/5eeaf56d5acb419d64e654799458e118 to your computer and use it in GitHub Desktop.
Replace and add custom script templates for Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#locating unity folder | |
if [ "$#" -gt 0 ] | |
then | |
unityFolder=${1%/} | |
else | |
unityFolder="/Applications/Unity" | |
fi | |
originalTemplatePath="$unityFolder/Unity.app/Contents/Resources/ScriptTemplates" | |
if [ ! -d "$originalTemplatePath" ] | |
then | |
echo "Could not find script templates at '$originalTemplatePath'" | |
exit 0 | |
fi | |
customTemplatePath="`dirname "$0"`/unity templates" | |
originalTemplateBackupFile="$originalTemplatePath/backup.zip" | |
#create template backup folder | |
if [ ! -f "$originalTemplateBackupFile" ] | |
then | |
echo "Making backup of original templates" | |
# (cd "$originalTemplatePath"; pwd; zip -r "$originalTemplateBackupFile" *.txt) | |
zip -j -0 "$originalTemplateBackupFile" "$originalTemplatePath/"*.txt | |
fi | |
#replacing with custom templates | |
for customTemplateFile in "$customTemplatePath/"*.txt | |
do | |
templateFileName=`basename "$customTemplateFile"` | |
originalTemplateFile="$originalTemplatePath/$templateFileName" | |
#override original with custom template | |
if [ -f "$originalTemplateFile" ] | |
then | |
echo "overriding: $originalTemplateFile" | |
else | |
echo "adding: $originalTemplateFile" | |
fi | |
cp -f "$customTemplateFile" "$originalTemplateFile" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Manual (This only works on OS X):
unity templates
. Inside this folder you have your custom scripts. If you want to replace built in scripts, name them the same as the original ones..zip
file is made in the templates folder.