using GamingIsLove.Makinom;
using UnityEngine;
public class OrkScreenshotSaveHandler : MonoBehaviour // Propably will be a Custom Node later
{
//public SaveGameSettings Settings;
public string MyScreenshotPath; // Replace "ScreenshotPath" with the actual path
public void SaveHandler()
{
SaveGameSettings Settings = Maki.SaveGameSettings;
Settings.saveSlots += 1; // Just tried to increment the saveSlots number
Texture2D screenshotAsset = LoadTextureFromPath();
if (screenshotAsset != null)
{
// Create a Sprite using the loaded texture
Sprite screenshotSprite = Sprite.Create(
screenshotAsset,
new Rect(0, 0, loadedTexture.width, loadedTexture.height),
Vector2.zero
);
// Assign the loaded asset source to the settings
Settings.fileContent.data.icon.image.texture = new AssetSource<Sprite>(screenshotSprite);
}
}
private Texture2D LoadTextureFromPath()
{
// Check if the file exists
if (System.IO.File.Exists(MyScreenshotPath))
{
// Read the bytes from the file
byte[] fileData = System.IO.File.ReadAllBytes(MyScreenshotPath);
// Create a new texture and load the image data into it
Texture2D texture = new Texture2D(2, 2); // You can adjust the size as needed
if (texture.LoadImage(fileData))
{
return texture;
}
}
// If the file doesn't exist or couldn't be loaded, return null
return null;
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
My base idea was to take a screenshot as I did before in my own code, and show it in the UI next to the corresponding save slot, but:
I'm still a bit confused about how Ork's save system works in-depth.
In the 3D RPG tutorial "25 Start Menu & Save Games" there is a section about setting up the Save / Load we set up a text: "Select save/load slot: ", so I guess there must be a way for the framework to know the corresponding slot/datapath, so it can render out "Select save slot
: 1", etc. How can I get that slot index data to my code or UI so I can synchronize that with my screenshot solution?
I've also looked for something like SaveGameToSlot, LoadGameFromSlot schematics, but couldn't find any, so I guess, it's not possible to handle it manualy.
You can also contact me (contact@orkframework.com) in case you want to commission this feature to get your hands on it earlier than whenever I can get to it.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!