SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. namespace UnityEditor.XR.ARKit
  6. {
  7. internal class ARResourceGroup
  8. {
  9. public string name { get; set; }
  10. public ARResourceGroup(string name)
  11. {
  12. this.name = name;
  13. }
  14. public void AddResource(ARResource resource)
  15. {
  16. if (resource == null)
  17. throw new ArgumentNullException("resource");
  18. if (m_Resources.Contains(resource))
  19. throw new InvalidOperationException(string.Format("Duplicate resource '{0}` in group '{1}'", resource.name, name));
  20. m_Resources.Add(resource);
  21. }
  22. internal void Write(string pathToAssetCatalog)
  23. {
  24. string path = Path.Combine(pathToAssetCatalog, name + ".arresourcegroup");
  25. Directory.CreateDirectory(path);
  26. // Build the contents json and write each resource to disk
  27. var contents = new Json.ResourceGroup
  28. {
  29. info = new Json.AuthorInfo
  30. {
  31. version = 1,
  32. author = "unity"
  33. },
  34. resources = new Json.Filename[m_Resources.Count]
  35. };
  36. for (int i = 0; i < m_Resources.Count; ++i)
  37. {
  38. var resource = m_Resources[i];
  39. contents.resources[i].filename = resource.filename;
  40. resource.Write(path);
  41. }
  42. // Finally, write out the json contents
  43. File.WriteAllText(Path.Combine(path, "Contents.json"), JsonUtility.ToJson(contents));
  44. }
  45. List<ARResource> m_Resources = new List<ARResource>();
  46. }
  47. }