I was testing out Easy save with my weapon system which uses this form of weapon checking
Code: Select all
namespace PlayerLoadoutSwitch{
public enum primary{mp5 = 0, akTac = 1, skorpion = 3};
public enum secondary{fiveseven = 0};
public enum lethal{grenade = 0};
public enum tactical{flashbang = 0};
public enum activeWeapon{mp5 = 0, aktac = 1, skorpion = 2, fiveseven = 3, grenade = 4, flashbang = 5};
[Header("Current Weapons")]
[SerializeField] private primary playersPrimary;
[SerializeField] private secondary playersSecondary;
[SerializeField] private lethal playersLethal;
[SerializeField] private tactical playersTactical;
[Header("Selected Weapon")]
public activeWeapon playersActiveWeapon;
What really matters here is the active weapon, that is all im trying to change between loads & saves
This is then my DataManager
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayerLoadoutSwitch;
public class ManagerScript : MonoBehaviour
{
[Header("Current Position")]
[Header("Current Head")]
[Header("Objective Completed")]
[Header("Current Weapon & Loadout")]
public WeaponSwitching_Manager awR;
public activeWeapon aw;
[Header("Player Ammo Bag")]
public Weapon_Ammo playerAmmoBag;
[Header("Weapons Current Ammo")]
public MP5_Player mp5;
}
Code: Select all
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayerLoadoutSwitch;
public class SaveSystem : MonoBehaviour
{
public ManagerScript ms;
public void Save()
{
ManagerScript script = ms.GetComponent<ManagerScript>();
ES3.Save("Current Weapon", script.aw);
ES3.Save("9MM", script.playerAmmoBag.nineMM);
}
}
Code: Select all
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayerLoadoutSwitch;
public class LoadSystem : MonoBehaviour
{
public ManagerScript ms;
public void Load()
{
ManagerScript script = ms.GetComponent<ManagerScript>();
script.aw = ES3.Load<activeWeapon>("Current Weapon");
Debug.Log("Loading " + script.aw.ToString());
script.playerAmmoBag.nineMM = ES3.Load<int>("9MM");
}
}
The issue is that when i save, it creates an enum save path with a value of 0 no matter what enum i saved, even if it was the enum 3 fiveseven. Then when i load, it says everytime it has loaded enum 0 (mp5) only even if i pull out a different weapon then load it says its loading the mp5 yet the wepaon doesnt change!
Any help would be great, if you need more info please lmk
Some of the code might be messy but thats just cause ive been trying other things for it & if it didnt break the compiler i continued, probs a bad habit