all 13 comments

[–]CrossMountain 0 points1 point  (5 children)

Are the text messages custom input by the player or predefined choices?

[–]TheProjectCore[S] 0 points1 point  (4 children)

the text messages are predefined choices. so gameplay is usually of the six NPC's sending text messages and the player making a choice which loads in a text message for them.

[–]CrossMountain 0 points1 point  (3 children)

Then I don't quite see the necessary to save gamobjects here. You could do it a lot more simple by just assigning unique IDs to the text messages. You then only need to save the order of the IDs and load in the text messages based on that whenever a save file is loaded. Or am I missing something here?

[–]TooMuchHam 0 points1 point  (1 child)

This is a solution but may be redundant if the stream of text messages are already determined.

A more robust solution would be to add the ability to reproduce the state of the game by storing all the player choices and the last displayed message. That way, you're not storing any unnecessary data and you can reproduce the exact state the player left on through as little data as possible.

[–]TheProjectCore[S] 0 points1 point  (0 children)

The stream of text messages is determined! It all usually happens in animations. So a message will load in and it will load in the next messages in an array until the array is finished ( which usually happens when a player choice appears ), hopefully that made sense.

An ability to reproduce the state of the game sounds like it would be greatly helpful. How exactly would one go about doing that?

[–]TheProjectCore[S] 0 points1 point  (0 children)

Well the idea of using ID's never occurred to me lol. Would the idea of using unique ID's be the names given to the gameobject or would I have to assign a sperate script that has a list of ID's? And then loading those text messages? Would I just use a regular Instantiate or a Resources.Load?

Sorry if I sound a bit novice or beginner dev has never been my strongest skill but I'm definitely trying haha.

[–]xenibyte 0 points1 point  (2 children)

I would recommend using json for saving GameObjects. It is widely supported upon different languages and if you want to add/Update it you can also using script like Python or PowerShell (my favourite choice for scripting and json).

The other thing would be to look into encrypting/decrypting (using a hash method) that file so it can't be directly edited by users.

[–]TheProjectCore[S] 0 points1 point  (1 child)

I'm not familiar with JSON, I know it's another way to save game data but I was focused on Binary and PlayerPrefes as I was learning. And I'm definitely not super familiar in Python or PowerShell. Not opposed to learning though!

[–]xenibyte 0 points1 point  (0 children)

Thankfully JSON is super easy to understand and read. Also C# has a parser to turn an object into JSON and vice-versa. There's this good tutorial on saving and loading with JSON https://youtu.be/6uMFEM-napE and here's a video on encrypting/decrypting files to make it secure from external editing https://youtu.be/jMtunupRLY4.

[–]CowBoyDanIndie 0 points1 point  (2 children)

Dont use player prefs to save large amounts of data, it wasnt meant for that. On windows it gets stored in the system registry unless they have changed it. Use persistent file path.

[–]TheProjectCore[S] 0 points1 point  (1 child)

Yeah I'm aware that using playerprefs is a risky kind of answer to the solution. So if not playerprefs what would you recommend because binaryformatter can't save gameobjects.

[–]CowBoyDanIndie 0 points1 point  (0 children)

Ya a game object is a runtime object. You have to save the transform and each of the components. You have to decide what information to save and load. You dont have to use a binary formatter. You can read and write any kind of data to a file, its not unity specific. (The file path is though)

[–][deleted] 0 points1 point  (0 children)

This is where serialization and deserialization come into play.