// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System.IO; using UltimateXR.Manipulation.HandPoses; using UnityEditor; using UnityEngine; namespace UltimateXR.Editor.Manipulation.HandPoses { /// /// Stores a that can be used as a preset to modify other hands. /// It also allows to show a thumbnail in the editor by looking for an image with the same pose name in the folder. /// public class UxrHandPosePreset { #region Public Types & Data /// /// Gets the hand pose asset. /// public UxrHandPoseAsset Pose { get; } /// /// Gets the thumbnail, or null if it wasn't found. /// public Texture2D Thumbnail { get; } #endregion #region Constructors & Finalizer /// /// Constructor that initializes the preset. /// /// File that contains a scriptable object /// /// List of other files in the folder which will be used to look for a thumbnail with the same name as the pose /// public UxrHandPosePreset(string file, string[] sameFolderFiles) { Pose = AssetDatabase.LoadAssetAtPath(file); foreach (string otherFile in sameFolderFiles) { if (otherFile != file && Path.GetFileNameWithoutExtension(otherFile) == Path.GetFileNameWithoutExtension(file) && AssetDatabase.GetMainAssetTypeAtPath(otherFile) == typeof(Texture2D)) { Thumbnail = AssetDatabase.LoadAssetAtPath(otherFile); } } } #endregion } }