PrefabSavingUtil.cs 546 B

123456789101112131415161718
  1. using System;
  2. using System.Reflection;
  3. using UnityEditor.Experimental.SceneManagement;
  4. public class PrefabSavingUtil {
  5. public static void SavePrefab(PrefabStage prefabStage)
  6. {
  7. if (prefabStage == null)
  8. throw new ArgumentNullException();
  9. var savePrefabMethod = prefabStage.GetType().GetMethod("SavePrefab", BindingFlags.NonPublic | BindingFlags.Instance);
  10. if (savePrefabMethod == null)
  11. throw new InvalidOperationException();
  12. savePrefabMethod.Invoke(prefabStage, null);
  13. }
  14. }