例如我需要两个HP与SP两个值在全局中进行访问:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "point")]
public class Points : ScriptableObject
{
public int HP;
public int SP;
}
然后我在预制体中创建point脚本化对象,将这个对象附加到其他预制体上,便能实现全局访问了,改变的均为此脚本化对象中的数据值:
原文:https://www.cnblogs.com/faust38290/p/14684445.html