Created
November 19, 2022 06:51
-
-
Save atori708/f2c4700a7094d41541d52051d8d62c10 to your computer and use it in GitHub Desktop.
【Unity】シーンの変更を破棄する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine.SceneManagement; | |
using System.Reflection; | |
public class DiscardChangeSceneAsset | |
{ | |
/// <summary> | |
/// シーンの変更を破棄する | |
/// </summary> | |
/// <param name="scene"></param> | |
public void DiscardChange(Scene scene) | |
{ | |
// 一応再生中は実行できないようにしておく | |
if (EditorApplication.isPlaying) { | |
return; | |
} | |
typeof(UnityEditor.SceneManagement.EditorSceneManager).InvokeMember( | |
"ReloadScene", | |
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, | |
null, | |
null, | |
new object[] { scene } | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment