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

相关推荐
蒙双眼看世界1 天前
Unity结合ECharts图表及网页插件EmbeddedBrowser的应用开发
unity·游戏引擎·echarts
郝学胜-神的一滴1 天前
中级OpenGL教程 004:为几何体注入法线灵魂
c++·unity·游戏引擎·godot·图形渲染·opengl·unreal
LF男男3 天前
GameManager.cs
unity
郝学胜-神的一滴4 天前
[简化版 GAMES 101] 计算机图形学 07:图形学投影完全推导
c++·unity·图形渲染·three.js·unreal engine
Avalon7125 天前
Unity3D响应式渲染UI框架UniVue
游戏·ui·unity·c#·游戏引擎
ellis19705 天前
Unity UI性能优化一之插件【Unity UI Optimization Tool】
unity·性能优化
xxx1x1x5 天前
电脑老是报错?原来是 DLL 文件缺失
dll文件·dll·dll修复·dll缺失·dll一键修复·dll查找
Zik----5 天前
Unity基础学习笔记(B站视频课整理)
unity·vr
郝学胜-神的一滴6 天前
罗德里格斯旋转公式(Rodrigues‘ Rotation Formula)完整推导
c++·unity·godot·图形渲染·three.js·unreal
田鸡_6 天前
Unity新输入系统(Input System)教学篇
unity·游戏引擎·游戏程序