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

相关推荐
浅陌sss12 小时前
Unity中可靠的UDP实现
unity
奔跑的犀牛先生18 小时前
unity学习46:反向动力学IK
unity
幻世界20 小时前
【工具插件类教学】实现运行时2D物体交互的利器Runtime2DTransformInteractor
unity·交互·运行时2d物体交互
音视频牛哥2 天前
Unity实现高性能多实例RTSP|RTMP播放器技术实践
unity·游戏引擎·音视频·实时音视频·大牛直播sdk·rtsp播放器·rtsp player
Artistation Game2 天前
三、Unity基础(主要框架)
游戏·unity·c#·游戏引擎
Edision_li2 天前
DeepSeek教unity------MessagePack-03
unity·messagepack
lalapanda2 天前
Unity学习part2
学习·unity·游戏引擎
CODE_RabbitV2 天前
【快速入门】Unity 常用组件(功能块)
unity·游戏引擎
BuHuaX2 天前
Unity-New Input System
unity·c#·游戏引擎·游戏程序·lucene
Edision_li3 天前
DeepSeek教unity------UI框架
学习·ui·unity·c#