fix: Sidekick 에디터 자동 실행 방지

- Sidekick Character Tool과 Downloader가 메뉴 실행 시에만 열리도록 수동 실행 플래그를 추가
- 데이터베이스 초기화 실패 및 로딩 상태 null 참조 방어 처리 추가
- TMP 한글 폰트 에셋의 글리프/문자 테이블 갱신
This commit is contained in:
2026-06-16 14:18:07 +09:00
parent 98b34af941
commit d45835facc
6 changed files with 813 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 936b212f6c1cb68aaab2cbd3180f4d7a guid: 272ca4c45d498854a9723b5a933c89ff
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@@ -48,6 +48,7 @@ namespace Synty.SidekickCharacters
private const string _BLEND_SHAPE_HEAVY_NAME = "defaultHeavy"; private const string _BLEND_SHAPE_HEAVY_NAME = "defaultHeavy";
private const string _BLEND_SHAPE_SKINNY_NAME = "defaultSkinny"; private const string _BLEND_SHAPE_SKINNY_NAME = "defaultSkinny";
private const string _AUTO_OPEN_STATE = "syntySkAutoOpenState"; private const string _AUTO_OPEN_STATE = "syntySkAutoOpenState";
private const string _MANUAL_OPEN_SESSION_KEY = "syntySkManualOpenRequested";
private const string _OUTPUT_MODEL_NAME = "Combined Character"; private const string _OUTPUT_MODEL_NAME = "Combined Character";
private const string _PART_COUNT_BODY = " parts in library"; private const string _PART_COUNT_BODY = " parts in library";
private const string _TEXTURE_COLOR_NAME = "ColorMap.png"; private const string _TEXTURE_COLOR_NAME = "ColorMap.png";
@@ -183,7 +184,7 @@ namespace Synty.SidekickCharacters
/// <inheritdoc cref="OnDestroy" /> /// <inheritdoc cref="OnDestroy" />
private void OnDestroy() private void OnDestroy()
{ {
if (_useAutoSaveAndLoad) if (_useAutoSaveAndLoad && _currentSpecies != null && _currentCharacter != null)
{ {
SerializedCharacter savedCharacter = CreateSerializedCharacter(_OUTPUT_MODEL_NAME); SerializedCharacter savedCharacter = CreateSerializedCharacter(_OUTPUT_MODEL_NAME);
Serializer serializer = new Serializer(); Serializer serializer = new Serializer();
@@ -192,13 +193,20 @@ namespace Synty.SidekickCharacters
} }
// ensures we release the file lock on the database // ensures we release the file lock on the database
_dbManager.CloseConnection(); _dbManager?.CloseConnection();
} }
#if UNITY_EDITOR #if UNITY_EDITOR
/// <inheritdoc cref="OnEnable" /> /// <inheritdoc cref="OnEnable" />
private void OnEnable() private void OnEnable()
{ {
if (!SessionState.GetBool(_MANUAL_OPEN_SESSION_KEY, false))
{
_useAutoSaveAndLoad = false;
Close();
return;
}
EditorApplication.playModeStateChanged += StateChange; EditorApplication.playModeStateChanged += StateChange;
EditorApplication.update += AnimationUpdate; EditorApplication.update += AnimationUpdate;
} }
@@ -211,7 +219,7 @@ namespace Synty.SidekickCharacters
/// <inheritdoc cref="Update" /> /// <inheritdoc cref="Update" />
private void Update() private void Update()
{ {
if (_loadingContent) if (_loadingContent && _loadingImage != null)
{ {
Vector3 rotation = _loadingImage.transform.rotation.eulerAngles; Vector3 rotation = _loadingImage.transform.rotation.eulerAngles;
rotation += new Vector3(0, 0, 0.5f * Time.deltaTime); rotation += new Vector3(0, 0, 0.5f * Time.deltaTime);
@@ -461,6 +469,7 @@ namespace Synty.SidekickCharacters
public async void CreateGUI() public async void CreateGUI()
{ {
_loadingContent = true; _loadingContent = true;
_loadingImage = null;
InitializeEditorWindow(); InitializeEditorWindow();
_root = rootVisualElement; _root = rootVisualElement;
_root.Clear(); _root.Clear();
@@ -469,10 +478,23 @@ namespace Synty.SidekickCharacters
_root.styleSheets.Add(_editorStyle); _root.styleSheets.Add(_editorStyle);
} }
try
{
InitializeDatabase(); InitializeDatabase();
}
catch (Exception ex)
{
_loadingContent = false;
_dbManager?.CloseConnection();
_dbManager = null;
Debug.LogWarning($"Failed to initialize Sidekick database. Please check the database file.\n{ex.Message}");
return;
}
// if we still can't connect, something's gone wrong, don't keep building the GUI // if we still can't connect, something's gone wrong, don't keep building the GUI
if (_dbManager?.GetCurrentDbConnection() == null) if (_dbManager?.GetCurrentDbConnection() == null)
{ {
_loadingContent = false;
return; return;
} }
@@ -804,6 +826,7 @@ namespace Synty.SidekickCharacters
} }
catch catch
{ {
_loadingContent = false;
Debug.LogWarning("Failed to load tool data. Please try again.\nPlease note that data loading may take some time."); Debug.LogWarning("Failed to load tool data. Please try again.\nPlease note that data loading may take some time.");
} }
} }

View File

@@ -12,38 +12,11 @@ using UnityEngine;
namespace Synty.SidekickCharacters.UI namespace Synty.SidekickCharacters.UI
{ {
[InitializeOnLoad]
public static class MenuBootstrapController public static class MenuBootstrapController
{ {
private const string _AUTO_OPEN_STATE = "syntySkAutoOpenState"; private const string _MANUAL_OPEN_SESSION_KEY = "syntySkManualOpenRequested";
private const string _PREFS_CHECK_NAME = "syntySKCheckDependencies";
private static ModularCharacterWindow _sidekickCharacterWindow; private static ModularCharacterWindow _sidekickCharacterWindow;
private static bool _openWindowOnStart = true;
static MenuBootstrapController()
{
EditorApplication.update += OpenWindowOnStartup;
}
/// <summary>
/// Opens the Character Creator window when Unity starts or the plugin is added to a project.
/// </summary>
private static void OpenWindowOnStartup()
{
_openWindowOnStart = EditorPrefs.GetBool(_AUTO_OPEN_STATE, true);
EditorApplication.update -= OpenWindowOnStartup;
if (_openWindowOnStart)
{
if (!SessionState.GetBool("FirstInitDone", false))
{
ShowSidekickCharacterWindow();
SessionState.SetBool("FirstInitDone", true);
}
}
}
/// <summary> /// <summary>
/// Creates the Sidekick Character Creator window and adds it to the toolbar. /// Creates the Sidekick Character Creator window and adds it to the toolbar.
@@ -51,6 +24,7 @@ namespace Synty.SidekickCharacters.UI
[MenuItem("Synty/Sidekick Character Tool")] [MenuItem("Synty/Sidekick Character Tool")]
public static void ShowSidekickCharacterWindow() public static void ShowSidekickCharacterWindow()
{ {
SessionState.SetBool(_MANUAL_OPEN_SESSION_KEY, true);
FindSidekickCharacterWindow(); FindSidekickCharacterWindow();
_sidekickCharacterWindow.Show(); _sidekickCharacterWindow.Show();
} }

View File

@@ -28,12 +28,19 @@ namespace Synty.SidekickCharacters
private const string _VERSION_TAG = "\"tag_name\":"; private const string _VERSION_TAG = "\"tag_name\":";
private const string _VERSION_KEY = "sk_current_tool_version"; private const string _VERSION_KEY = "sk_current_tool_version";
private const string _SIDEKICK_TOOL_MENU_ITEM = "Synty/Sidekick Character Tool"; private const string _SIDEKICK_TOOL_MENU_ITEM = "Synty/Sidekick Character Tool";
private const string _MANUAL_OPEN_SESSION_KEY = "syntySkDownloaderManualOpenRequested";
private string _version = "-"; private string _version = "-";
private Label _latestVersion; private Label _latestVersion;
public void Awake() public void Awake()
{ {
if (!SessionState.GetBool(_MANUAL_OPEN_SESSION_KEY, false))
{
Close();
return;
}
BackgroundUpdateCheck(); BackgroundUpdateCheck();
} }
@@ -288,21 +295,16 @@ namespace Synty.SidekickCharacters
} }
/// <summary> /// <summary>
/// Creates an instance of the Downloader Tool, to allow checks for new versions on editor startup. /// 메뉴에서 요청한 경우에만 다운로더 도구를 생성하고 연다.
/// </summary> /// </summary>
[InitializeOnLoad]
public static class DownloaderBackgroundService public static class DownloaderBackgroundService
{ {
private static ToolDownloader _instance; private const string _MANUAL_OPEN_SESSION_KEY = "syntySkDownloaderManualOpenRequested";
static DownloaderBackgroundService() private static ToolDownloader _instance;
{
EditorApplication.update += CreateToolInstance;
}
static void CreateToolInstance() static void CreateToolInstance()
{ {
EditorApplication.update -= CreateToolInstance;
EditorWindow[] allWindows = Resources.FindObjectsOfTypeAll<EditorWindow>(); EditorWindow[] allWindows = Resources.FindObjectsOfTypeAll<EditorWindow>();
// Filter the windows to find the one with the desired type name // Filter the windows to find the one with the desired type name
@@ -343,6 +345,7 @@ namespace Synty.SidekickCharacters
[MenuItem("Synty/Sidekick Tool Downloader")] [MenuItem("Synty/Sidekick Tool Downloader")]
public static void ShowToolDownloaderWindow() public static void ShowToolDownloaderWindow()
{ {
SessionState.SetBool(_MANUAL_OPEN_SESSION_KEY, true);
if (_instance == null) if (_instance == null)
{ {
CreateToolInstance(); CreateToolInstance();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long