This repository has been archived on 2020-08-22. You can view files and clone it, but cannot push or open issues or pull requests.
flutter-unity-view-widget/example/unity/ARDemoApp/Library/PackageCache/com.unity.xr.arkit@3.0.0-pr.../Editor/ARResourceGroup.cs

58 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace UnityEditor.XR.ARKit
{
internal class ARResourceGroup
{
public string name { get; set; }
public ARResourceGroup(string name)
{
this.name = name;
}
public void AddResource(ARResource resource)
{
if (resource == null)
throw new ArgumentNullException("resource");
if (m_Resources.Contains(resource))
throw new InvalidOperationException(string.Format("Duplicate resource '{0}` in group '{1}'", resource.name, name));
m_Resources.Add(resource);
}
internal void Write(string pathToAssetCatalog)
{
string path = Path.Combine(pathToAssetCatalog, name + ".arresourcegroup");
Directory.CreateDirectory(path);
// Build the contents json and write each resource to disk
var contents = new Json.ResourceGroup
{
info = new Json.AuthorInfo
{
version = 1,
author = "unity"
},
resources = new Json.Filename[m_Resources.Count]
};
for (int i = 0; i < m_Resources.Count; ++i)
{
var resource = m_Resources[i];
contents.resources[i].filename = resource.filename;
resource.Write(path);
}
// Finally, write out the json contents
File.WriteAllText(Path.Combine(path, "Contents.json"), JsonUtility.ToJson(contents));
}
List<ARResource> m_Resources = new List<ARResource>();
}
}