Version: 2019.3
LanguageEnglish
  • C#

AssetDatabase.StopAssetEditing

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static void StopAssetEditing();

Description

Stops importing Assets into the Asset Database. This lets you group several Asset imports together into one larger import.

Note:
Calling AssetDatabase.StartAssetEditing() places the Asset Database in a state that will prevent imports until AssetDatabase.StopAssetEditing() is called. This means that if an exception occurs between the two function calls, the AssetDatabase will be unresponsive. Therefore, it is highly recommended that you place calls to AssetDatabase.StartAssetEditing() and AssetDatabase.StopAssetEditing() inside either a try..catch block, or a try..finally block as needed.

using UnityEngine;
using UnityEditor;

public class StartStopAssetEditingExample : MonoBehaviour { [MenuItem("APIExamples/StartStopAssetEditing")] static void CallAssetDatabaseAPIsBetweenStartStopAssetEditing() { try { //Place the Asset Database in a state where //importing is suspended for most APIs AssetDatabase.StartAssetEditing();

AssetDatabase.CopyAsset("Assets/CopyAsset.txt", "Assets/Text/CopyAsset.txt"); AssetDatabase.MoveAsset("Assets/MoveAsset.txt", "Assets/Text/MoveAsset.txt"); } finally { //By adding a call to StopAssetEditing inside //a "finally" block, we ensure the AssetDatabase //state will be reset when leaving this function AssetDatabase.StopAssetEditing(); } } }