121 lines
3.0 KiB
C#
121 lines
3.0 KiB
C#
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
|
|
public class SceneOpener : Editor
|
|
{
|
|
static string m_strTargetPath = string.Empty;
|
|
|
|
static void SaveScene(UnityEngine.SceneManagement.Scene _scene)
|
|
{
|
|
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(_scene);
|
|
}
|
|
|
|
static void OpenScene(string _strPath)
|
|
{
|
|
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(_strPath);
|
|
}
|
|
|
|
static bool EqualsScene(string _strPath)
|
|
{
|
|
if (true == UnityEngine.SceneManagement.SceneManager.GetActiveScene().path.Equals(_strPath))
|
|
{
|
|
if (true == EditorUtility.DisplayDialog("Warning", "Same Scene..", "Load", "Cancel"))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static bool CheckErrorMessage()
|
|
{
|
|
if (true == EditorApplication.isPlaying
|
|
|| true == EditorApplication.isCompiling
|
|
|| true == EditorApplication.isPaused
|
|
|| true == EditorApplication.isUpdating)
|
|
{
|
|
if (true == EditorUtility.DisplayDialog("Error", "Unity is Busy..\n\n(Playing || Compiling || Paused || Updating..)", "Ok"))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static void CheckSaveScene()
|
|
{
|
|
var active_scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
|
if (active_scene.isDirty == false)
|
|
return;
|
|
if (true == EditorUtility.DisplayDialog("Save Scene", "Are You Save Current Scene?", "Ok", "Cancel"))
|
|
{
|
|
SaveScene(active_scene);
|
|
}
|
|
}
|
|
|
|
[MenuItem("Scene Opener/타이틀", false, 1)]
|
|
static void LoadSceone_Title()
|
|
{
|
|
if (true == CheckErrorMessage())
|
|
return;
|
|
|
|
m_strTargetPath = "Assets/Scenes/Title.unity";
|
|
|
|
if (true == EqualsScene(m_strTargetPath))
|
|
return;
|
|
|
|
CheckSaveScene();
|
|
|
|
OpenScene(m_strTargetPath);
|
|
}
|
|
|
|
[MenuItem("Scene Opener/인게임", false, 2)]
|
|
static void LoadSceone_InGame()
|
|
{
|
|
if (true == CheckErrorMessage())
|
|
return;
|
|
|
|
m_strTargetPath = "Assets/Scenes/InGame.unity";
|
|
|
|
if (true == EqualsScene(m_strTargetPath))
|
|
return;
|
|
|
|
CheckSaveScene();
|
|
|
|
OpenScene(m_strTargetPath);
|
|
}
|
|
|
|
[MenuItem("Scene Opener/애니메이션 작업 툴", false, 3)]
|
|
static void LoadSceone_Settings()
|
|
{
|
|
if (true == CheckErrorMessage())
|
|
return;
|
|
|
|
m_strTargetPath = "Assets/Scenes/Settings.unity";
|
|
|
|
if (true == EqualsScene(m_strTargetPath))
|
|
return;
|
|
|
|
CheckSaveScene();
|
|
|
|
OpenScene(m_strTargetPath);
|
|
}
|
|
[MenuItem("Scene Opener/데미지 테스트", false, 4)]
|
|
static void LoadSceone_StatTest()
|
|
{
|
|
if (true == CheckErrorMessage())
|
|
return;
|
|
|
|
m_strTargetPath = "Assets/Scenes/StatTest.unity";
|
|
|
|
if (true == EqualsScene(m_strTargetPath))
|
|
return;
|
|
|
|
CheckSaveScene();
|
|
|
|
OpenScene(m_strTargetPath);
|
|
}
|
|
}
|
|
#endif |