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

相关推荐
qq 180809511 天前
从零构建一个多目标多传感器融合跟踪器
unity
平行云1 天前
实时云渲染支持在网页上运行UE5开发的3A大作Lyra项目
unity·云原生·ue5·webgl·虚拟现实·实时云渲染·像素流送
鹏飞于天1 天前
Shader compiler initialization error: Failed to read D3DCompiler DLL file
unity
wonder135791 天前
UGUI重建流程和优化
unity·游戏开发·ugui
那个村的李富贵1 天前
Unity打包Webgl后 本地运行测试
unity·webgl
nnsix1 天前
Unity OpenXR开发HTC Vive Cosmos
unity·游戏引擎
nnsix1 天前
Unity OpenXR,扳机键交互UI时,必须按下扳机才触发
unity·游戏引擎
nnsix1 天前
Unity XR 编辑器VR设备模拟功能
unity·编辑器·xr
老朱佩琪!1 天前
Unity访问者模式
unity·游戏引擎·访问者模式
不定时总结的那啥1 天前
Unity实现点击Console消息自动选中预制体的方法
unity·游戏引擎