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

相关推荐
奔跑的犀牛先生6 分钟前
unity学习56:旧版legacy和新版TMP文本输入框 InputField学习
unity
Thomas_YXQ1 天前
Unity3D 战斗系统架构与设计详解
开发语言·unity·架构·系统架构·unity3d
Nicole Potter1 天前
内存泄漏指什么?常见的内存泄漏有哪些?
开发语言·游戏·unity·面试·c#
Jditinpc1 天前
Unity FBXExport导出的FBX无法在Blender打开
unity·游戏引擎·blender
太妃糖耶2 天前
Unity地形系统
unity·游戏引擎
别偷喝船长的朗姆酒2 天前
【Unity】鱼群效果模拟
unity·游戏引擎
WarPigs3 天前
Unity汽车笔记
笔记·unity·汽车
奔跑的犀牛先生3 天前
unity学习52:UI的最基础组件 rect transform,锚点anchor,支点/轴心点 pivot
unity
奔跑的犀牛先生3 天前
unity学习53:UI的子容器:面板panel
unity
larito3 天前
HybridCLR+Adressable+Springboot热更
unity·热更