From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:08:29 +0800 Subject: + astar project --- .../Drawing/DrawingSettings.cs | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Drawing/DrawingSettings.cs (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Drawing/DrawingSettings.cs') diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Drawing/DrawingSettings.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Drawing/DrawingSettings.cs new file mode 100644 index 0000000..7af8883 --- /dev/null +++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Drawing/DrawingSettings.cs @@ -0,0 +1,74 @@ +#pragma warning disable CS0169, CS0414 // The field 'DrawingSettings.version' is never used +using UnityEditor; +using UnityEngine; + +namespace Pathfinding.Drawing { + /// Stores ALINE project settings + public class DrawingSettings : ScriptableObject { + public const string SettingsPathCompatibility = "Assets/Settings/ALINE.asset"; + public const string SettingsName = "AstarGizmos"; + public const string SettingsPath = "Assets/Settings/Resources/" + SettingsName + ".asset"; + + /// Stores ALINE project settings + [System.Serializable] + public class Settings { + /// Opacity of lines when in front of objects + public float lineOpacity = 1.0f; + + /// Opacity of solid objects when in front of other objects + + public float solidOpacity = 0.55f; + + /// Opacity of text when in front of other objects + + public float textOpacity = 1.0f; + + /// Additional opacity multiplier of lines when behind or inside objects + + public float lineOpacityBehindObjects = 0.12f; + + /// Additional opacity multiplier of solid objects when behind or inside other objects + + public float solidOpacityBehindObjects = 0.45f; + + /// Additional opacity multiplier of text when behind or inside other objects + + public float textOpacityBehindObjects = 0.9f; + + /// + /// Resolution of curves, as a fraction of the default. + /// + /// The resolution of curves is dynamic based on the distance to the camera. + /// This setting will make the curves higher or lower resolution by a factor from the default. + /// + public float curveResolution = 1.0f; + } + + [SerializeField] + private int version; + public Settings settings; + + public static Settings DefaultSettings => new Settings(); + + public static DrawingSettings GetSettingsAsset () { +#if UNITY_EDITOR + System.IO.Directory.CreateDirectory(Application.dataPath + "/../" + System.IO.Path.GetDirectoryName(SettingsPath)); + var settings = AssetDatabase.LoadAssetAtPath(SettingsPath); + if (settings == null && AssetDatabase.LoadAssetAtPath(SettingsPathCompatibility) != null) { + AssetDatabase.MoveAsset(SettingsPathCompatibility, SettingsPath); + settings = AssetDatabase.LoadAssetAtPath(SettingsPath); + } + if (settings == null) { + settings = ScriptableObject.CreateInstance(); + settings.settings = DefaultSettings; + settings.version = 0; + AssetDatabase.CreateAsset(settings, SettingsPath); + AssetDatabase.SaveAssets(); + } +#else + var settings = Resources.Load(SettingsName); +#endif + return settings; + } + } +} -- cgit v1.1-26-g67d0