I’ve searched internet for days and desperate to find for help. I need two scripts can reference the same SerializeField, which mean the modification of one on inspector can effect the other.
Could anyone please tell me the solution, I’m very appreciated.
This is where ScriptableObjects are helpful:
Let’s say you wanted a float to be shared between the objects - you can move that float into it’s own ScriptableObject script;
[CreateAssetMenu(fileName = "SharedFloat", menuName = "SharedFloat")]
public SharedFloat : ScriptableObject
public float value;
With the CreateAssetMenu attribute you can then create a new SharedFloat object in the project assets, within which you can add your value. Then, in your scripts, you can instead reference the SharedFloat object and drag in your created asset;
[SerializeField] private SharedFloat m_MyFloat;