using UnityEditor; using UnityEngine; namespace UnityEditor.TerrainTools { /// /// Class for creating NoiseSettings Assets. If you do not need to save the NoiseSettings /// to disk, consider using ScriptableObject.CreateInstance< NoiseSettings >() instead. /// internal class NoiseSettingsFactory { /// /// Creates a new NoiseSettings Asset in the root Assets folder. This is the function /// accessible via the "Assets/Create/Noise Settings" MenuItem /// /// A reference to the newly created NoiseSettings Asset d [MenuItem("Assets/Create/Noise Settings")] public static NoiseSettings CreateAsset() { return CreateAsset(AssetDatabase.GenerateUniqueAssetPath("Assets/New Noise Settings.asset")); } /// /// Creates a new NoiseSettings Asset at the specified Asset path /// /// The path in the AssetDatabase where the new NoiseSettings Asset should be saved /// A reference to the newly created NoiseSettings Asset public static NoiseSettings CreateAsset(string assetPath) { NoiseSettings noiseSettings = ScriptableObject.CreateInstance(); assetPath = AssetDatabase.GenerateUniqueAssetPath(assetPath); AssetDatabase.CreateAsset(noiseSettings, assetPath); AssetDatabase.SaveAssets(); EditorGUIUtility.PingObject(noiseSettings); return noiseSettings; } } }