dllllllllllllll🥓
🥙vs创建类库项目
🧀添加UnityEngine、UnityEditor引用
右键引用
,添加引用
找到unity 安装目录下的:\Editor\Data\Managed
🍕添加MonoBehaviour类
csharp
using UnityEngine;
namespace ClassLibrary
{
public class TestMono:MonoBehaviour
{
[SerializeField,Header("当前进度")]
private float currentProgress = 0;
[Header("进度更新事件")]
public UnityEngine.Events.UnityEvent<float> onProgressEvent;
void Start ()
{
Debug.Log(gameObject.name);
}
void Update() {
if(Input.GetKeyDown(KeyCode.Escape))
{
UpdateProgress(currentProgress+0.1f);
}
}
public void UpdateProgress(float progress) {
currentProgress =Mathf.Clamp01(progress);
onProgressEvent?.Invoke(progress);
}
}
}
🦪设置dll生成路径
🍿生成dll
🍔使用dll中的Mono类
把dll 复制到项目中,直接把Mono类拖到物体上即可