Answers for "unity serializable"

C#
4

unity serializable

using System;
using UnityEngine;public class Player : MonoBehaviour
{
    //Create a custom struct and apply [Serializable] attribute to it
    [Serializable]
    public struct PlayerStats
    {
        public int movementSpeed;
        public int hitPoints;
        public bool hasHealthPotion;
    }    //Make the private field of our PlayerStats struct visible in the Inspector
    //by applying [SerializeField] attribute to it
    [SerializeField]
    private PlayerStats stats;
}
Posted by: Guest on July-21-2020

C# Answers by Framework

Browse Popular Code Answers by Language