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

相关推荐
__water14 小时前
RHK《Unity接入PicoSDK入门》
unity·游戏引擎·picosdk
我的golang之路果然有问题14 小时前
unity 资源导入 godot
unity·游戏引擎·godot
迪普阳光开朗很健康15 小时前
Unity+Vscode+EmmyLua+XLua 调试实战
vscode·unity·游戏引擎
Var_al15 小时前
Unity编辑器扩展:标准化UI组件快速创建工具开发指南
ui·unity·c#·编辑器
CreasyChan15 小时前
Unity 中的 IEnumerator协程详解
unity·c#·游戏引擎
熬夜敲代码的小N16 小时前
基于Unity开发Pico VR眼镜基础应用:从环境搭建到实战部署全解析
人工智能·unity·游戏引擎·vr
王维志1 天前
使用C#控制台批量删除 Unity目录里的 .meta文件
unity·c#·.net
avi91111 天前
Unity 天命6源码- 商业游戏说明分析
开发语言·unity·c#·游戏开发·游戏源码
世洋Blog1 天前
Unity脚本生命周期(全)
unity·游戏引擎
DowneyJoy1 天前
【多媒体交互】透明无边框窗口
unity·c#·.net·交互