public static void CreateAssetCoverStatConfig() { ScriptableObjectLibrary.CreateAsset <RecipeAsset>(); }
/// <summary> /// /// </summary> public static void CreateAsset <T>() where T : ScriptableObject { T asset = ScriptableObject.CreateInstance <T>(); string path = AssetDatabase.GetAssetPath(Selection.activeObject); if (string.IsNullOrEmpty(path)) { path = ASSETS_PATH; } else if (!string.IsNullOrEmpty(Path.GetExtension(path))) { path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), string.Empty); } if (!string.IsNullOrEmpty(path)) { string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + ScriptableObjectLibrary.GetTypeNameWithoutNamespace <T>() + ASSET_EXTENSION); AssetDatabase.CreateAsset(asset, assetPathAndName); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; } else { UnityEngine.Debug.LogError("[CustomAssetUtility] Invalid asset path"); } }