Asset.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. namespace sc.modeling.river.editor
  6. {
  7. public static class Asset
  8. {
  9. public const string NAME = "River Modeler";
  10. public const string VERSION = "1.0.4";
  11. public const int ID = 263898;
  12. #region Installer
  13. internal abstract class Installer : sc.modeling.water.common.editor.PackageInstaller
  14. {
  15. private static readonly string[] requiredPackages =
  16. {
  17. "com.unity.splines@2.3.0",
  18. "com.unity.mathematics",
  19. "com.unity.visualeffectgraph",
  20. "com.unity.shadergraph"
  21. };
  22. //Symbols defined by assembly definition
  23. #if !SPLINES || !MATHEMATICS || !VFX_GRAPH || !SHADERGRAPH
  24. [InitializeOnLoadMethod]
  25. private static void AutoInstall()
  26. {
  27. InstallDependencies(NAME, requiredPackages);
  28. }
  29. [MenuItem("River Modeler/Install dependencies")]
  30. private static void InstallMenuFunction()
  31. {
  32. AutoInstall();
  33. }
  34. #endif
  35. }
  36. #endregion
  37. public static class Preferences
  38. {
  39. public static bool ShowToolPoints
  40. {
  41. get => EditorPrefs.GetBool(PlayerSettings.productName + "_RIVER_EDITOR_ShowToolPoints", false);
  42. private set => EditorPrefs.SetBool(PlayerSettings.productName + "_RIVER_EDITOR_ShowToolPoints", value);
  43. }
  44. public static bool RebuildEveryFrame
  45. {
  46. get => EditorPrefs.GetBool(PlayerSettings.productName + "_RM_RebuildEveryFrame", true);
  47. set => EditorPrefs.SetBool(PlayerSettings.productName + "_RM_RebuildEveryFrame", value);
  48. }
  49. [SettingsProvider]
  50. public static SettingsProvider ScreenshotSettings()
  51. {
  52. var provider = new SettingsProvider($"Preferences/Water Geometry Tools/River", SettingsScope.User)
  53. {
  54. label = "River Editor",
  55. guiHandler = (searchContent) =>
  56. {
  57. EditorGUILayout.LabelField($"v{Asset.VERSION}", EditorStyles.miniLabel);
  58. EditorGUILayout.Space();
  59. ShowToolPoints = EditorGUILayout.ToggleLeft("Show tool points", ShowToolPoints);
  60. EditorGUILayout.HelpBox("When enabled, data points for tools such as Width and Opacity will always be displayed on rivers, even when not active.\n\n", MessageType.Info);
  61. RebuildEveryFrame = EditorGUILayout.Toggle("Rebuild every frame", RebuildEveryFrame);
  62. EditorGUILayout.HelpBox("When disabled, the river mesh is rebuild at a lower frame rate when changing parameters in the inspector. This yields better editor performance." +
  63. "\n\nWhen enabled, rebuilding occurs every time the UI repaints (much smoother)", MessageType.Info);
  64. using (new EditorGUILayout.HorizontalScope())
  65. {
  66. GUILayout.FlexibleSpace();
  67. if (GUILayout.Button("Rebuild all instances in scene"))
  68. {
  69. int count = RiverEditor.RebuildAllInstances();
  70. Debug.Log($"Rebuilt {count} River Modeler component instances.");
  71. }
  72. }
  73. },
  74. keywords = new HashSet<string>(new[]
  75. {
  76. "River"
  77. })
  78. };
  79. return provider;
  80. }
  81. }
  82. }
  83. }