浏览代码

Add code comments

/4.0
Tim Mowrer 4 年前
当前提交
bb522997
共有 1 个文件被更改,包括 19 次插入3 次删除
  1. 22
      Assets/Scenes/ARCollaborationData/Editor/CollaborationBuildPostprocessor.cs

22
Assets/Scenes/ARCollaborationData/Editor/CollaborationBuildPostprocessor.cs


namespace UnityEditor.XR.ARFoundation.Samples
{
class Processor : IPostprocessBuildWithReport, IPreprocessBuildWithReport
/// <summary>
/// This build processor finds all <see cref="CollaborativeSession"/> components in the build and adds the
/// necessary plist entries according to https://developer.apple.com/documentation/multipeerconnectivity
/// </summary>
class CollaborationBuildProcessor : IPostprocessBuildWithReport, IPreprocessBuildWithReport
{
public int callbackOrder => 2;

}
PlistElementArray GetOrCreatePlistElementArray(PlistElementDict dict, string key)
static PlistElementArray GetOrCreatePlistElementArray(PlistElementDict dict, string key)
/// <summary>
/// Adds necessary plist entries required by iOS 14+.
/// See https://developer.apple.com/documentation/multipeerconnectivity for details.
/// </summary>
/// <param name="report">The BuildReport provided by the post build process.</param>
void IPostprocessBuildWithReport.OnPostprocessBuild(BuildReport report)
{
if (report.summary.platform != BuildTarget.iOS)

plist.ReadFromString(File.ReadAllText(plistPath));
var root = plist.root;
// The app requires permission from the user to use the local network
// If no entry exists, then we will add one with the prompt "Collaborative Session"
// Get all the service names
// Collect all the service names we need to add
var bonjourServices = GetOrCreatePlistElementArray(root, "NSBonjourServices");
var existingValues = new HashSet<string>(bonjourServices.values
.Where(value => value is PlistElementString)

.Select(collaborativeSession => collaborativeSession.serviceType)
.Where(serviceType => !string.IsNullOrEmpty(serviceType)))
{
// Each "serviceType" must be registered as a Bonjour Service or the app will crash
// See https://developer.apple.com/documentation/bundleresources/information_property_list/nsbonjourservices
AddIfNecessary(existingValues, valuesToAdd, $"_{serviceType}._tcp");
AddIfNecessary(existingValues, valuesToAdd, $"_{serviceType}._udp");
}

valuesToAdd.Add(value);
}
/// <summary>
/// Collects all CollaborativeSession components from each scene in the final build
/// </summary>
[PostProcessScene]
static void OnPostProcessScene()
{

正在加载...
取消
保存