diff --git a/src/CacheObject/IValues/InteractiveString.cs b/src/CacheObject/IValues/InteractiveString.cs index 52d1f4d..269909c 100644 --- a/src/CacheObject/IValues/InteractiveString.cs +++ b/src/CacheObject/IValues/InteractiveString.cs @@ -80,7 +80,7 @@ namespace UnityExplorer.CacheObject.IValues return; } - var path = IOUtility.EnsureValidDirectory(SaveFilePath.Text); + var path = IOUtility.EnsureValidFilePath(SaveFilePath.Text); if (File.Exists(path)) File.Delete(path); diff --git a/src/Core/Utility/IOUtility.cs b/src/Core/Utility/IOUtility.cs index 2904e5a..d7975d9 100644 --- a/src/Core/Utility/IOUtility.cs +++ b/src/Core/Utility/IOUtility.cs @@ -11,14 +11,15 @@ namespace UnityExplorer private static readonly char[] invalidDirectoryCharacters = Path.GetInvalidPathChars(); private static readonly char[] invalidFilenameCharacters = Path.GetInvalidFileNameChars(); - public static string EnsureValidDirectory(string path) + public static string EnsureValidFilePath(string fullPathWithFile) { - path = string.Concat(path.Split(invalidDirectoryCharacters)); + // Remove invalid path characters + fullPathWithFile = string.Concat(fullPathWithFile.Split(invalidDirectoryCharacters)); - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); + // Create directory (does nothing if it exists) + Directory.CreateDirectory(Path.GetDirectoryName(fullPathWithFile)); - return path; + return fullPathWithFile; } public static string EnsureValidFilename(string filename) diff --git a/src/Inspectors/ReflectionInspector.cs b/src/Inspectors/ReflectionInspector.cs index 9eac3f2..aeec236 100644 --- a/src/Inspectors/ReflectionInspector.cs +++ b/src/Inspectors/ReflectionInspector.cs @@ -644,7 +644,7 @@ namespace UnityExplorer.Inspectors var fitter = imageObj.AddComponent(); fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; textureImage = imageObj.AddComponent(); - textureImageLayout = UIFactory.SetLayoutElement(imageObj, flexibleWidth: 9999, flexibleHeight: 9999); + textureImageLayout = UIFactory.SetLayoutElement(imageObj, flexibleWidth: 1, flexibleHeight: 1); textureViewer.SetActive(false); } @@ -664,6 +664,7 @@ namespace UnityExplorer.Inspectors textureImage.sprite = sprite; textureImageLayout.preferredHeight = sprite.rect.height; + // not really working, its always stretched horizontally for some reason. textureImageLayout.preferredWidth = sprite.rect.width; } @@ -688,7 +689,7 @@ namespace UnityExplorer.Inspectors return; } - path = IOUtility.EnsureValidDirectory(path); + path = IOUtility.EnsureValidFilePath(path); if (File.Exists(path)) File.Delete(path); @@ -699,7 +700,6 @@ namespace UnityExplorer.Inspectors tex = TextureUtilProvider.ForceReadTexture(tex); byte[] data = TextureUtilProvider.Instance.EncodeToPNG(tex); - File.WriteAllBytes(path, data); if (tex != TextureRef) diff --git a/src/Loader/MelonLoader/MelonLoaderConfigHandler.cs b/src/Loader/MelonLoader/MelonLoaderConfigHandler.cs index d11b4f4..fabb63c 100644 --- a/src/Loader/MelonLoader/MelonLoaderConfigHandler.cs +++ b/src/Loader/MelonLoader/MelonLoaderConfigHandler.cs @@ -34,7 +34,7 @@ namespace UnityExplorer.Loader.ML } } - // This wrapper exists to handle the arbitrary "LemonAction" delegates which ML now uses in 0.4.4+. + // This wrapper exists to handle the "LemonAction" delegates which ML now uses in 0.4.4+. // Reflection is required since the delegate type changed between 0.4.3 and 0.4.4. // A wrapper class is required to link the MelonPreferences_Entry and the delegate instance. public class EntryDelegateWrapper diff --git a/src/UI/Panels/LogPanel.cs b/src/UI/Panels/LogPanel.cs index a49502d..6f0babb 100644 --- a/src/UI/Panels/LogPanel.cs +++ b/src/UI/Panels/LogPanel.cs @@ -62,7 +62,7 @@ namespace UnityExplorer.UI.Panels private void SetupIO() { var path = Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Logs"); - path = IOUtility.EnsureValidDirectory(path); + path = IOUtility.EnsureValidFilePath(path); // clean old log(s) var files = Directory.GetFiles(path);