#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; } } }