Type 'RPG.Movement.Mover+MoverSaveData' in Assembly

I get the error Type ‘RPG.Movement.Mover+MoverSaveData’ in Assembly ‘Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ is not marked as serializable. when i try to save the console will print that it saved but then through error rightafter

this is my mover script

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.AI;

using RPG.Core;

using RPG.Saving;

namespace RPG.Movement

{

public class Mover : MonoBehaviour, IAction, ISaveable

{

    [SerializeField] Transform target;

    [SerializeField] float maxSpeed;

    // Ray lastRay;

    NavMeshAgent navMeshAgent;

    Health health;

    private void Start() {

        navMeshAgent = GetComponent<NavMeshAgent>();

        health = GetComponent<Health>();

    }

    // Update is called once per frame

    void Update()

    {

        navMeshAgent.enabled = !health.IsDead();

        UpdateAnimator();

    }

    public void StartMoveAction(Vector3 destination, float speedfraction)

    {

        GetComponent<ActionScheduler>().StartAction(this);

        MoveTo(destination, speedfraction);

    }

    public void MoveTo(Vector3 destination, float speedFraction)

    {

        navMeshAgent.destination = destination;

        navMeshAgent.speed = maxSpeed * Mathf.Clamp01(speedFraction);

        navMeshAgent.isStopped = false;

    }

    //MoveTo but its for crouching

    public void Cancel()

    {

        navMeshAgent.isStopped = true;

    }

    //Debug.DrawRay(lastRay.origin, lastRay.direction * 100);

    private void UpdateAnimator()

    {

        Vector3 velocity = navMeshAgent.velocity;

        Vector3 localVelocity = transform.InverseTransformDirection(velocity);

        GetComponent<Animator>().SetFloat("forwardSpeed", velocity.magnitude);

    }

    struct MoverSaveData

    {

        public SerializableVector3 position;

        public SerializableVector3 rotation;

    }

    public object CaptureState()

    {

        MoverSaveData data = new MoverSaveData();

        data.position = new SerializableVector3(transform.position);

        data.rotation = new SerializableVector3(transform.eulerAngles);

        return data;

    }

    public void RestoreState(object state)

    {

        MoverSaveData data = (MoverSaveData)state;

        GetComponent<NavMeshAgent>().enabled = false;

        transform.position = data.position.ToVector();

        transform.eulerAngles = data.rotation.ToVector();

        GetComponent<NavMeshAgent>().enabled = true;

    }

}

}

The MoverSaveData struct needs to be tagged with the [System.Serializable] decorator. It just tells the system that the entire struct (not just the contents) are serializable.

The bad news is that after you’ve fixed this, you’ll still need to delete the existing save file because the serialization error corrupted it.

Alright its done and it worked. thank you ! you are a big help.