Fix Sidekick tool startup and path handling

This commit is contained in:
2026-03-22 23:50:10 +09:00
parent 9d84154b54
commit c66c91e8e9
6 changed files with 345 additions and 20 deletions

View File

@@ -40,7 +40,7 @@ namespace Synty.SidekickCharacters
private const string _AUTOSAVE_MISSING_PARTS = "SK_Autosave_missing_parts";
private const string _AUTOSAVE_STATE = "SK_Autosave_state";
private const string _BASE_COLOR_SET_NAME = "Species";
private const string _BASE_COLOR_SET_PATH = "Assets/Synty/SidekickCharacters/Resources/Species";
private const string _BASE_COLOR_SET_PATH = "Assets/External/Models/SidekickCharacters/Resources/Species";
private const string _BASE_MESH_NAME = "Meshes/SK_BaseModel";
private const string _BASE_MATERIAL_NAME = "Materials/M_BaseMaterial";
private const string _BLEND_GENDER_NAME = "masculineFeminine";
@@ -121,7 +121,7 @@ namespace Synty.SidekickCharacters
private bool _showAllColourProperties = false;
private float _bodyTypeBlendValue;
private bool _loadingCharacter = false;
private bool _loadingContent = true;
private bool _loadingContent = false;
private Image _loadingImage;
private ObjectField _materialField;
private float _musclesBlendValue;
@@ -192,7 +192,7 @@ namespace Synty.SidekickCharacters
}
// ensures we release the file lock on the database
_dbManager.CloseConnection();
_dbManager?.CloseConnection();
}
#if UNITY_EDITOR
@@ -211,7 +211,7 @@ namespace Synty.SidekickCharacters
/// <inheritdoc cref="Update" />
private void Update()
{
if (_loadingContent)
if (_loadingContent && _loadingImage != null)
{
Vector3 rotation = _loadingImage.transform.rotation.eulerAngles;
rotation += new Vector3(0, 0, 0.5f * Time.deltaTime);
@@ -473,6 +473,7 @@ namespace Synty.SidekickCharacters
// if we still can't connect, something's gone wrong, don't keep building the GUI
if (_dbManager?.GetCurrentDbConnection() == null)
{
_loadingContent = false;
return;
}
@@ -1814,7 +1815,12 @@ namespace Synty.SidekickCharacters
documentationButton.clickable.clicked += delegate
{
Application.OpenURL("file:Assets/Synty/SidekickCharacters/Documentation/SidekickCharacters_UserGuide.pdf");
string documentationPath = Path.Combine(DatabaseManager.GetPackageRootAbsolutePath() ?? string.Empty, "Documentation", "SidekickCharacters_UserGuide.pdf");
documentationPath = Path.GetFullPath(documentationPath);
if (File.Exists(documentationPath))
{
Application.OpenURL("file:" + documentationPath);
}
};
Button storeButton = new Button
@@ -1919,7 +1925,8 @@ namespace Synty.SidekickCharacters
/// </summary>
private void SaveColorSet()
{
string path = Path.Combine(_BASE_COLOR_SET_PATH, _currentSpecies.Name);
string baseColorSetPath = DatabaseManager.GetPackageAssetPath("Resources", "Species") ?? _BASE_COLOR_SET_PATH;
string path = Path.Combine(baseColorSetPath, _currentSpecies.Name);
path = Path.Combine(path, _currentColorSet.Name.Replace(" ", "_"));
SaveTexturesToDisk(path);

View File

@@ -24,7 +24,7 @@ namespace Synty.SidekickCharacters
private const string _GIT_DB_URL = "https://github.com/SyntyStudios/SidekicksToolRelease/releases/latest/download/SidekicksDatabase.unitypackage";
private const string _PACKAGE_CACHE = "Assets/DownloadCache/Sidekicks.unitypackage";
private const string _DB_PACKAGE_CACHE = "Assets/DownloadCache/SidekicksDatabase.unitypackage";
private const string _VERSION_FILE = "Assets/Synty/SidekickCharacters/Scripts/Editor/version.txt";
private const string _VERSION_FILE_NAME = "version.txt";
private const string _VERSION_TAG = "\"tag_name\":";
private const string _VERSION_KEY = "sk_current_tool_version";
private const string _SIDEKICK_TOOL_MENU_ITEM = "Synty/Sidekick Character Tool";
@@ -168,19 +168,61 @@ namespace Synty.SidekickCharacters
private void SaveCurrentInstalledVersion(string version)
{
File.WriteAllText(_VERSION_FILE, version);
string versionFilePath = GetVersionFilePath();
if (string.IsNullOrEmpty(versionFilePath))
{
Debug.LogWarning("Unable to resolve Sidekick version file path.");
return;
}
File.WriteAllText(versionFilePath, version);
}
private string LoadCurrentInstalledVersion()
{
if (File.Exists(_VERSION_FILE))
string versionFilePath = GetVersionFilePath();
if (string.IsNullOrEmpty(versionFilePath))
{
return File.ReadAllText(_VERSION_FILE);
return null;
}
if (File.Exists(versionFilePath))
{
return File.ReadAllText(versionFilePath);
}
return null;
}
private string GetVersionFilePath()
{
MonoScript currentScript = MonoScript.FromScriptableObject(this);
if (currentScript == null)
{
return null;
}
string scriptPath = AssetDatabase.GetAssetPath(currentScript);
if (string.IsNullOrEmpty(scriptPath))
{
return null;
}
string utilityDirectory = Path.GetDirectoryName(scriptPath);
if (string.IsNullOrEmpty(utilityDirectory))
{
return null;
}
string editorDirectory = Path.GetDirectoryName(utilityDirectory);
if (string.IsNullOrEmpty(editorDirectory))
{
return null;
}
return Path.GetFullPath(Path.Combine(editorDirectory, _VERSION_FILE_NAME));
}
private void DownloadLatestDBVersion()
{
WebClient client = new WebClient();