unity make a class serializable code example
Example 1: unity serializable
using System;
using UnityEngine;public class Player : MonoBehaviour
{
[Serializable]
public struct PlayerStats
{
public int movementSpeed;
public int hitPoints;
public bool hasHealthPotion;
}
[SerializeField]
private PlayerStats stats;
}
Example 2: how to access serializable class objects unity
public class A1 : MonoBehaviour
{
User1 user = new User1();
private void Start()
{
user.Start();
}
public void OnMouseDown()
{
Debug.Log(user.BB);
}
}