up
This commit is contained in:
66
Assets/3rd/NativeCamera/Plugins/Editor/NCPostProcessBuild.cs
Normal file
66
Assets/3rd/NativeCamera/Plugins/Editor/NCPostProcessBuild.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
|
||||
public class NCPostProcessBuild
|
||||
{
|
||||
private const bool ENABLED = true;
|
||||
|
||||
private const string CAMERA_USAGE_DESCRIPTION = "Capture media with camera";
|
||||
private const string MICROPHONE_USAGE_DESCRIPTION = "Capture microphone input in videos";
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
public static void ValidatePlugin()
|
||||
{
|
||||
string jarPath = "Assets/Plugins/NativeCamera/Android/NativeCamera.jar";
|
||||
if( File.Exists( jarPath ) )
|
||||
{
|
||||
Debug.Log( "Deleting obsolete " + jarPath );
|
||||
AssetDatabase.DeleteAsset( jarPath );
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
#pragma warning disable 0162
|
||||
[PostProcessBuild]
|
||||
public static void OnPostprocessBuild( BuildTarget target, string buildPath )
|
||||
{
|
||||
if( !ENABLED )
|
||||
return;
|
||||
|
||||
if( target == BuildTarget.iOS )
|
||||
{
|
||||
string pbxProjectPath = PBXProject.GetPBXProjectPath( buildPath );
|
||||
string plistPath = Path.Combine( buildPath, "Info.plist" );
|
||||
|
||||
PBXProject pbxProject = new PBXProject();
|
||||
pbxProject.ReadFromFile( pbxProjectPath );
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string targetGUID = pbxProject.GetUnityFrameworkTargetGuid();
|
||||
#else
|
||||
string targetGUID = pbxProject.TargetGuidByName( PBXProject.GetUnityTargetName() );
|
||||
#endif
|
||||
|
||||
pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-framework MobileCoreServices" );
|
||||
pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-framework ImageIO" );
|
||||
|
||||
File.WriteAllText( pbxProjectPath, pbxProject.WriteToString() );
|
||||
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromString( File.ReadAllText( plistPath ) );
|
||||
|
||||
PlistElementDict rootDict = plist.root;
|
||||
rootDict.SetString( "NSCameraUsageDescription", CAMERA_USAGE_DESCRIPTION );
|
||||
rootDict.SetString( "NSMicrophoneUsageDescription", MICROPHONE_USAGE_DESCRIPTION );
|
||||
|
||||
File.WriteAllText( plistPath, plist.WriteToString() );
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0162
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa3b57e342928704cb910789ae4dde20
|
||||
timeCreated: 1521452119
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "NativeCamera.Editor",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31117d0234af0084b91a7e53b3d9e0a3
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user