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

相关推荐
垂葛酒肝汤15 小时前
Unity的UI扫光效果Shader
ui·unity·游戏引擎
mxwin19 小时前
Unity Shader Alpha测试 · 模板测试 · 深度测试
unity·游戏引擎
Sator11 天前
unity解决粒子与物体接触时的硬边缘问题
unity·游戏引擎
okk1kk1 天前
一键修复 DLL 缺失报错!彻底解决程序闪退、找不到入口点难题
dll文件·dll·dll修复·dll缺失·dll恢复
程序员JerrySUN1 天前
Jetson边缘嵌入式实战课程第三讲:L4T 与 Jetson 系统架构
linux·服务器·人工智能·安全·unity·系统架构·游戏引擎
萌萌的提莫队长1 天前
Unity HDRP 渲染管线 Camera 输出到RenderTexture没有Alpha通道
unity·游戏引擎
winlife_1 天前
Unity Editor 工具不该用反射写组件字段:SerializedObject 在 4 个场景里非用不可
unity·自动化·游戏引擎
星河耀银海1 天前
Unity C#入门:变量的定义与访问权限(public/private)
unity·c#·lucene
郝学胜-神的一滴1 天前
中级OpenGL教程 005:为球体&平面注入法线灵魂
c++·unity·图形渲染·three.js·opengl·unreal
那个村的李富贵1 天前
unity编辑器工具,输出使用的字体
unity·编辑器·游戏引擎