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

相关推荐
Flamesky13 小时前
Unity编辑器重新编译代码
unity·重新编译
qq_5982117571 天前
Unity.UGUI DrawCall合批笔记
笔记·unity·游戏引擎
Tech Synapse2 天前
Unity ML-Agents实战指南:构建多技能游戏AI训练系统
人工智能·游戏·unity
咩咩觉主2 天前
c#数据结构 线性表篇 非常用线性集合总结
开发语言·数据结构·unity·c#·游戏引擎·程序框架
浅陌sss3 天前
Unity中AssetBundle使用整理(一)
unity·游戏引擎
KhalilRuan3 天前
Unity-Shader详解-其五
unity·游戏引擎
惊鸿醉3 天前
Unity C# 中的 反射 小记
unity·c#·游戏引擎
Yuze_Neko3 天前
C#异步Task,await,async和Unity同步协程
开发语言·unity·c#
七月.末3 天前
【Unity】Unity中修改网格的大小和倾斜网格
unity·游戏引擎
蔗理苦4 天前
2025-05-07 Unity 网络基础7——TCP异步通信
网络·tcp/ip·unity·异步通信