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

相关推荐
weixin_424294676 小时前
Unity的测试Edit Mode和Play Mode,有什么区别?
unity
玖玥拾10 小时前
Unity 3D 笔记(八)ScrollRect 滚动视图、NavMesh 自动寻路系统
笔记·3d·unity
淡海水1 天前
06-04-YooAsset源码-Unity加密解密服务
前端·unity·性能优化·c#·游戏引擎·yooasset
fogota2 天前
【AI】C# .NET8 WPF 第三方DLL引用配置(编译不丢失、不自动删除)
c#·.net·wpf·dll
cd_949217212 天前
Unity游戏角色资产怎么快速制作?用V2Fun跑通生成、绑定和导入测试
游戏·unity·游戏引擎
HH‘HH2 天前
Unity 项目创建标准指南:分辨率、尺寸、文件路径与命名规范
unity·游戏引擎
元气少女小圆丶2 天前
unity发布web嵌入到前端页面的接受参数
前端·unity·webgl
HH‘HH2 天前
Unity 打包程序设置及注意事项全攻略
unity·游戏引擎
qq_170264752 天前
unity里 Burst的用法
unity·游戏引擎