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

相关推荐
向宇it1 小时前
【unity实战】MapMagic 2实战例子
游戏·3d·unity·c#·游戏引擎
SlowFeather2 小时前
Unity TMP可控角度多色渐变文字
unity·游戏引擎
霜绛8 小时前
Unity:UGUI笔记(一)——三大基础控件、组合控件
笔记·学习·unity·游戏引擎
小趴菜822714 小时前
Android中加载unity aar包实现方案
android·unity·游戏引擎
今夕资源网1 天前
牛童三国单机游戏Unity源码 免费开源
游戏·unity·单机游戏·游戏源码·unity源码·unity游戏
future_studio1 天前
聊聊 Unity(小白专享、C# 小程序 之 图片播放器)
unity·小程序·c#
ellis19702 天前
toLua[七] Examples 06_LuaCoroutine2分析
unity
L X..2 天前
Unity 光照贴图异常修复笔记
unity·c#·游戏引擎
Xeon_CC2 天前
打开多个Unity编辑器时使用Visual Studio调试,弹出选择Unity实例窗口,但是没有实例
unity·编辑器·visual studio·调试·unity 调试
future_studio3 天前
聊聊 Unity(小白专享、熟悉基础编程 ... ...)
unity·游戏引擎