// Copyright (c) 2024 Synty Studios Limited. All rights reserved. // // Use of this software is subject to the terms and conditions of the Synty Studios End User Licence Agreement (EULA) // available at: https://syntystore.com/pages/end-user-licence-agreement // // For additional details, see the LICENSE.MD file bundled with this software. #if UNITY_EDITOR using System; using UnityEditor; using UnityEditor.Callbacks; namespace Synty.SidekickCharacters.UI { public static class SkAssetOpenHandler { #if UNITY_6000_3_OR_NEWER /// /// Opens .sk assets double clicked in the Project window in the Sidekick Character Tool. /// /// The entity ID of the opened asset. /// The line number the asset was opened at (unused). /// True if the asset was handled; otherwise false. [OnOpenAsset] public static bool OnOpenSkAsset(UnityEngine.EntityId entityId, int line) { return OpenSkAsset(AssetDatabase.GetAssetPath(entityId)); } #else /// /// Opens .sk assets double clicked in the Project window in the Sidekick Character Tool. /// /// The instance ID of the opened asset. /// The line number the asset was opened at (unused). /// True if the asset was handled; otherwise false. [OnOpenAsset] public static bool OnOpenSkAsset(int instanceID, int line) { return OpenSkAsset(AssetDatabase.GetAssetPath(instanceID)); } #endif /// /// Opens the asset at the given path in the Sidekick Character Tool if it is a .sk file. /// /// The asset path of the opened asset. /// True if the asset was handled; otherwise false. private static bool OpenSkAsset(string path) { if (string.IsNullOrEmpty(path) || !path.EndsWith(".sk", StringComparison.OrdinalIgnoreCase)) { return false; } ModularCharacterWindow.OpenAndLoadCharacter(path); return true; } } } #endif