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.

66 lines
2.8 KiB

4 years ago
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Linq;
  4. using UnityEngine;
  5. namespace UnityEditor.XR.ARKit
  6. {
  7. public static class ARKitSettingsProvider
  8. {
  9. [SettingsProvider]
  10. static SettingsProvider CreateSettingsProvider()
  11. {
  12. GUIContent s_WarningToCreateSettings = EditorGUIUtility.TrTextContent(
  13. "This controls the Build Settings for ARKit.\n\nYou must create a serialized instance of the settings data in order to modify the settings in this UI. Until then only default settings set by the provider will be available.");
  14. // First parameter is the path in the Settings window.
  15. // Second parameter is the scope of this setting: it only appears in the Project Settings window.
  16. var provider = new SettingsProvider("Project/XR/ARKit", SettingsScope.Project)
  17. {
  18. // By default the last token of the path is used as display name if no label is provided.
  19. label = "ARKit Build Settings",
  20. // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
  21. guiHandler = (searchContext) =>
  22. {
  23. if (ARKitSettings.currentSettings == null)
  24. {
  25. EditorGUILayout.HelpBox(s_WarningToCreateSettings);
  26. if (GUILayout.Button(EditorGUIUtility.TrTextContent("Create")))
  27. {
  28. Create();
  29. }
  30. else
  31. {
  32. return;
  33. }
  34. }
  35. var serializedSettings = ARKitSettings.GetSerializedSettings();
  36. EditorGUILayout.PropertyField(serializedSettings.FindProperty("m_Requirement"), new GUIContent(
  37. "Requirement",
  38. "Toggles whether ARKit is required for this app. This will make the app only downloadable by devices with ARKit support if set to 'Required'."));
  39. serializedSettings.ApplyModifiedProperties();
  40. },
  41. // Populate the search keywords to enable smart search filtering and label highlighting:
  42. keywords = new HashSet<string>(new[] { "ARKit", "optional", "required" })
  43. };
  44. return provider;
  45. }
  46. static void Create()
  47. {
  48. var path = EditorUtility.SaveFilePanelInProject("Save ARKit Settings", "ARKitSettings", "asset", "Please enter a filename to save the ARKit settings.");
  49. if (string.IsNullOrEmpty(path))
  50. return;
  51. var settings = ScriptableObject.CreateInstance<ARKitSettings>();
  52. AssetDatabase.CreateAsset(settings, path);
  53. ARKitSettings.currentSettings = settings;
  54. }
  55. }
  56. }