unity rename populated list varibale code example

Example: unity rename populated list varibale

//To rename a List or Variable in Unity without
// loosing the references/populated data:
using UnityEngine;
using UnityEngine.Serialization;

//Add "FormerlySerializedAs" with your current Variable name
[FormerlySerializedAs("myPreviousListName")]
public List<GameObject> myPreviousListName = new List<GameObject>();

//Save the script and switch to the inspector.

//Going back to your Script you can now insert your new name:

[FormerlySerializedAs("myPreviousListName")]
public List<GameObject> myNewListName = new List<GameObject>();

//Saving and switching to Inspector again and wait for the name to change

//(OPTIONAL) Remove "FormerlySerializedAs"

public List<GameObject> myNewListName = new List<GameObject>();

Tags:

Misc Example