Unity MonoBehaviour 生成dll

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类拖到物体上即可

相关推荐
不伤欣5 小时前
游戏设计模式 - 子类沙箱
游戏·unity·设计模式
lv_fu9 小时前
调用.net DLL让CANoe自动识别串口号
.net·dll·capl·canoe·vid pid·自动串口
快乐觉主吖11 小时前
Unity的日志管理类
android·unity·游戏引擎
WarPigs19 小时前
Unity性能优化笔记
笔记·unity·游戏引擎
T.D.C1 天前
【业务框架】3C-相机-Cinemachine
unity
Clank的游戏栈2 天前
Unity基于GraphView的可视化关卡编辑器开发指南
unity·编辑器·游戏引擎
海尔辛2 天前
Unity UI 性能优化--Sprite 篇
ui·unity·性能优化
XR-AI-JK2 天前
Unity VR/MR开发-VR设备与适用场景分析
unity·vr·mr
ChiLi_Lin2 天前
Unity异常上报飞书工具
unity·游戏引擎·飞书
地狱为王3 天前
基于VLC的Unity视频播放器(四)
unity·游戏引擎·音视频