Açıklama Yok
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.

UniversalProjectSettings.cs 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.IO;
  2. using UnityEngine;
  3. using UnityEditorInternal;
  4. namespace UnityEditor.Rendering.Universal
  5. {
  6. internal class UniversalProjectSettings : ScriptableObject
  7. {
  8. public static string filePath => "ProjectSettings/URPProjectSettings.asset";
  9. //preparing to eventual migration later
  10. enum Version
  11. {
  12. None,
  13. First
  14. }
  15. [SerializeField]
  16. int m_LastMaterialVersion = k_NeverProcessedMaterialVersion;
  17. internal const int k_NeverProcessedMaterialVersion = -1;
  18. public static int materialVersionForUpgrade
  19. {
  20. get => instance.m_LastMaterialVersion;
  21. set
  22. {
  23. instance.m_LastMaterialVersion = value;
  24. }
  25. }
  26. //singleton pattern
  27. static UniversalProjectSettings s_Instance;
  28. static UniversalProjectSettings instance => s_Instance ?? CreateOrLoad();
  29. UniversalProjectSettings()
  30. {
  31. s_Instance = this;
  32. }
  33. static UniversalProjectSettings CreateOrLoad()
  34. {
  35. //try load
  36. InternalEditorUtility.LoadSerializedFileAndForget(filePath);
  37. //else create
  38. if (s_Instance == null)
  39. {
  40. UniversalProjectSettings created = CreateInstance<UniversalProjectSettings>();
  41. created.hideFlags = HideFlags.HideAndDontSave;
  42. }
  43. System.Diagnostics.Debug.Assert(s_Instance != null);
  44. return s_Instance;
  45. }
  46. internal static void Save()
  47. {
  48. if (s_Instance == null)
  49. {
  50. Debug.Log("Cannot save ScriptableSingleton: no instance!");
  51. return;
  52. }
  53. string folderPath = Path.GetDirectoryName(filePath);
  54. if (!Directory.Exists(folderPath))
  55. Directory.CreateDirectory(folderPath);
  56. InternalEditorUtility.SaveToSerializedFileAndForget(new[] { s_Instance }, filePath, allowTextSerialization: true);
  57. }
  58. }
  59. }