Skip to content

Commit

Permalink
Update unity plugin to work with Unity 5
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisliu committed Aug 28, 2015
1 parent c3e1a8a commit d38de0a
Show file tree
Hide file tree
Showing 54 changed files with 221 additions and 1,844 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[Tt]emp/
[Oo]bj/

*.meta
*.pyc

# Autogenerated VS/MD solution and project files
Expand Down
5 changes: 5 additions & 0 deletions Assets/Amplitude.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Amplitude/Amplitude.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Amplitude/MiniJSON.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/Editor/PostprocessBuildPlayer.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 18 additions & 22 deletions Assets/Editor/PostprocessBuildPlayer_Amplitude
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import os, sys
import subprocess
import objc_helper
import os_helper
import glob
from mod_pbxproj import XcodeProject
import re
from subprocess import call

argv = sys.argv
Expand All @@ -21,29 +19,27 @@ editorFolder = os.path.split(scriptName)[0]
assetsFolder = os.path.split(editorFolder)[0]
app_controller_helper_path = os.path.join(installPath, "Libraries/AppControllerHelper.h")

if player == 'iPhone':

def rewrite_unity_xcode_project(unity_xcode_project_path):
#
# Copying Libraries
# Setting GCC Objective C exceptions to TRUE
#
amplitudeLocation = os.path.join(assetsFolder, "Plugins/iOS/Amplitude")
newAmplitudeLocation = os.path.join(installPath, "Classes")
os_helper.copy(amplitudeLocation, newAmplitudeLocation)

unity_xcode_lines = []
# allow objective-c exceptions
re_objc_excep = re.compile(r"\s*GCC_ENABLE_OBJC_EXCEPTIONS *= *NO.*")
with open(unity_xcode_project_path) as upf:
for line in upf:
if re_objc_excep.match(line):
print "matched line: {0}", re_objc_excep.match(line).group()
line = line.replace("NO","YES")
print "Objective-c exceptions enabled"
unity_xcode_lines.append(line)
with open(unity_xcode_project_path, "w+") as upf:
upf.writelines(unity_xcode_lines)

if player == 'iPhone':
#
# Modifying the XCode project, messy!
#
pbxProjPath = os.path.join(installPath, "Unity-iPhone.xcodeproj/project.pbxproj")
project = XcodeProject.Load(pbxProjPath)
classes = project.get_or_create_group('Classes')
amplitude = project.get_or_create_group('Amplitude', path='Amplitude', parent=classes, tree='<group>')
for f in sorted(glob.glob(newAmplitudeLocation + '/Amplitude/*.[hm]')):
project.add_file(os.path.basename(f), parent=amplitude, tree='<group>')

project.add_file('System/Library/Frameworks/UIKit.framework', tree='SDKROOT')
project.save()

#
# Setting GCC Objective C exceptions to TRUE
#
objc_helper.set_flag(pbxProjPath, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES")
rewrite_unity_xcode_project(pbxProjPath)
4 changes: 4 additions & 0 deletions Assets/Editor/PostprocessBuildPlayer_Amplitude.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/Editor/java_helper.py.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d38de0a

Please sign in to comment.