UniRx 插件入门

unity免费插件之unirx UniRx 是一个用于 Unity 的响应式编程库,它通过响应式编程的模式来简化事件和异步操作的管理。 阅读详情

在完善 Unity 开发的游戏框架时,看到框架 TinaX

使用了 TweenRx 插件 TweenRx

而这个插件,又使用到了一个名为 UniRx 的插件 UniRx

看到框架 QFramework 也用到了该插件 QFramework

于是了解了响应式编程这个概念,经过一番学习之后,个人理解是:

这是一种基于异步通信数据流的编程模式。
这个流的最大特点是:
每一个数据都可以转化为流;
对流的操作,产生新的流;
数据变化后,中间的“操作”是不变的,会使用同一个处理流程。

它是一种全新的编程理念,可以让我们更加关注于业务逻辑,而非程序逻辑,这大大启发了我。

这一篇主要记录下这个插件的基本使用方法。

学习的过程中,除了参考官方的 README.md 之外,也参考了这些资料:

Unity UniRX中文教程-Chinar
什么是响应式编程
The introduction to Reactive Programming you’ve been missing

UniRx 是什么?

官方 README :

UniRx (Reactive Extensions for Unity) is a reimplementation of the .NET Reactive Extensions. The Official Rx implementation is great but doesn’t work on Unity and has issues with iOS IL2CPP compatibility. This library fixes those issues and adds some specific utilities for Unity. Supported platforms are PC/Mac/Android/iOS/WebGL/WindowsStore/etc and the library.

UniRx 全称 Reactive Extensions for Unity,它重新实现了 .NET Reactive Extensions,官方的Rx (Reactive Extensions)虽然很给力,但是无法在 Unity 上正常的工作,而且在 iOS IL2CPP 的兼容性上有些问题。UniRx 修复了这些问题,并为 Unity 额外添加了一些特殊的工具。支持的平台包括 PC/Mac/Android/iOS/WebGL/WindowsStore 等等。

它不但在 Github 上开源,而且在 Unity 插件商店 也是免费的。

为什么要用 UniRx?

总结官方的话,就是这几个点:
1、Unity 中经常要使用的 Coroutine,对于异步操作不好用;
怎么不好用?
1.1、Coroutine 返回对是 IEnumerator 对象,而不是一些值对象(Coroutines can’t return any values, since its return type must be IEnumerator.)
1.2、异常处理不友好(Coroutines can’t handle exceptions, because yield return statements cannot be surrounded with a try-catch construction.)

那么 UniRx 的特点是什么?官方的原话如下:

UniRx is a library for composing asynchronous and event-based programs using observable collections and LINQ-style query operators.
The game loop (every Update, OnCollisionEnter, etc), sensor data (Kinect, Leap Motion, VR Input, etc.) are all types of events. Rx represents events as reactive sequences which are both easily composable and support time-based operations by using LINQ query operators.
Unity is generally single threaded but UniRx facilitates multithreading for joins, cancels, accessing GameObjects, etc.
UniRx helps UI programming with uGUI. All UI events (clicked, valuechanged, etc) can be converted to UniRx event streams.
Unity supports async/await from 2017 with C# upgrades, UniRx family prjects provides more lightweight, more powerful async/await integration with Unity. Please see CySharp/UniTask.
https://github.com/Cysharp/UniTask

以下可忽略,基本和官方一致。
UniRx 怎么用?

官方示例:捕获用户双击鼠标事件

using System;
using UnityEngine;
using UnityEngine.UI;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{
    [SerializeField] Text m_Text = null;

    void Start()
    {
        var clickStream = Observable.EveryUpdate().Where(_ => Input.GetMouseButtonDown(0));
        clickStream.Buffer(clickStream.Throttle(TimeSpan.FromMilliseconds(250)))
            .Where(xs => xs.Count >= 2)
            .Subscribe(xs => Debug.LogFormat("DoubleClick Detected! Count: {0}", xs.Count));
    }
}

网络操作(官方不建议使用 ObservableWWW)
通用

using UnityEngine;
using UnityEngine.UI;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{
    void Start()
    {
        ObservableWWW.Get("http://google.co.jp/")
            .Subscribe(
                x => Debug.Log(x.Substring(0, 100)), // onSuccess
                ex => Debug.LogException(ex)); // onError
            }
}
  1. 可组合也可取消,还可以使用 LINQ 类型的表达式
using UnityEngine;
using UnityEngine.UI;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{
    [SerializeField] Text m_Text = null;

    void Start()
    {
        // composing asynchronous sequence with LINQ query expressions
        var query = from google in ObservableWWW.Get("http://google.com/")
                    from bing in ObservableWWW.Get("http://bing.com/")
                    from unknown in ObservableWWW.Get(google + bing)
                    select new { google, bing, unknown };

        var cancel = query.Subscribe(x => Debug.Log(x));

        // Call Dispose is cancel.
        cancel.Dispose();
    }
}
  1. 并行
// Observable.WhenAll is for parallel asynchronous operation
// (It's like Observable.Zip but specialized for single async operations like Task.WhenAll)
var parallel = Observable.WhenAll(
    ObservableWWW.Get("http://google.com/"),
    ObservableWWW.Get("http://bing.com/"),
    ObservableWWW.Get("http://unity3d.com/"));

parallel.Subscribe(xs =>
{
    Debug.Log(xs[0].Substring(0, 100)); // google
    Debug.Log(xs[1].Substring(0, 100)); // bing
    Debug.Log(xs[2].Substring(0, 100)); // unity
});
  1. 下载以及通知 ObservableWWW / ScheduledNotifier
using UnityEngine;
using UnityEngine.UI;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{
    [SerializeField] Text m_Text = null;

    void Start()
    {
        var _progressNotifier = new ScheduledNotifier<float>();
        ObservableWWW.GetAndGetBytes("https://github.com/neuecc/UniRx/releases/download/7.1.0/UniRx.unitypackage", progress: _progressNotifier).Subscribe();
        _progressNotifier.Subscribe(progressFloat => {
            Debug.Log("progress >> " + progressFloat);
        });
        _progressNotifier.SubscribeToText(m_Text);
    }
}
  1. 封装 Coroutine 的功能
// public method
public static IObservable<string> GetWWW(string url)
{
    // convert coroutine to IObservable
    return Observable.FromCoroutine<string>((observer, cancellationToken) => GetWWWCore(url, observer, cancellationToken));
}

// IObserver is a callback publisher
// Note: IObserver's basic scheme is "OnNext* (OnError | Oncompleted)?" 
static IEnumerator GetWWWCore(string url, IObserver<string> observer, CancellationToken cancellationToken)
{
    var www = new UnityEngine.WWW(url);
    while (!www.isDone && !cancellationToken.IsCancellationRequested)
    {
        yield return null;
    }

    if (cancellationToken.IsCancellationRequested) yield break;

    if (www.error != null)
    {
        observer.OnError(new Exception(www.error));
    }
    else
    {
        observer.OnNext(www.text);
        observer.OnCompleted(); // IObserver needs OnCompleted after OnNext!
    }
}

使用

void Start()
{
    var req = GetWWW("https://www.baidu.com")
        .Subscribe(
            x => Debug.Log(x.Substring(0, 100)), // onSuccess
            ex => Debug.LogException(ex)); // onError
}
  1. 调用多个 OnNext 的例子(同时告诉我们如何将一个对象转为 IObservable 类型对象)
public static IObservable<float> ToObservable(this UnityEngine.AsyncOperation asyncOperation)
{
    if (asyncOperation == null) throw new ArgumentNullException("asyncOperation");

    return Observable.FromCoroutine<float>((observer, cancellationToken) => RunAsyncOperation(asyncOperation, observer, cancellationToken));
}

static IEnumerator RunAsyncOperation(UnityEngine.AsyncOperation asyncOperation, IObserver<float> observer, CancellationToken cancellationToken)
{
    while (!asyncOperation.isDone && !cancellationToken.IsCancellationRequested)
    {
        observer.OnNext(asyncOperation.progress);
        yield return null;
    }
    if (!cancellationToken.IsCancellationRequested)
    {
        observer.OnNext(asyncOperation.progress); // push 100%
        observer.OnCompleted();
    }
}

// usecase
Application.LoadLevelAsync("testscene")
    .ToObservable()
    .Do(x => Debug.Log(x)) // output progress
    .Last() // last sequence is load completed
    .Subscribe();

如何每一帧调用某个函数? Observable.EveryUpdate()

using UnityEngine;
using UniRx;

public class MyUniRx_EveryUpdate : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Observable.EveryUpdate().Subscribe(_ =>
        {
            Debug.Log("EveryUpdate");
        });
    }
}

EveryUpdate().First() 第一帧执行

using UnityEngine;
using UniRx;

public class MyUniRx_EveryUpdate : MonoBehaviour
{
    void Start()
    {
        Observable.EveryUpdate()
            .First()
            .Subscribe(_ =>
            {
                Debug.Log("EveryUpdate");
            });
    }
}

First(过滤条件),按下鼠标左键时执行

using UnityEngine;
using UniRx;

public class MyUniRx_EveryUpdate : MonoBehaviour
{
    void Start()
    {
        Observable.EveryUpdate()
            .First(_ => Input.GetMouseButtonUp(0))
            .Subscribe(_ =>
            {
                Debug.Log("左键按下时执行,并且只执行一次");
            });
    }
}

AddTo 给事件流添加生命周期

using UnityEngine;
using UniRx;

public class MyUniRx_EveryUpdate : MonoBehaviour
{
    void Start()
    {
        Observable.EveryUpdate()
            .First(_ => Input.GetMouseButtonUp(0)).Subscribe(_ => {
                Debug.Log("Call On Left MouseButtonUp");
            })
            .AddTo(this); // 生命周期和 this 保持一致
    }
}

等价的写法

using UnityEngine;
using UniRx;
using UniRx.Triggers;

public class MyUniRx_EveryUpdate : MonoBehaviour
{
    void Start()
    {
        this.UpdateAsObservable()
            .First(_ => Input.GetMouseButtonUp(0)).Subscribe(_ => {
                Debug.Log("Call On Left MouseButtonUp");
            });
    }
}

Interval

Observable.Interval(TimeSpan.FromSeconds(1))
    .Subscribe(_ =>
    {
        Debug.Log("Interval");
    })
    .AddTo(this);

数据绑定绑定到 UI

using UnityEngine;
using UnityEngine.UI;
using UniRx;
using UniRx.Triggers;

public class MyUniRx_EveryUpdate : MonoBehaviour
{
    [SerializeField] Text m_Text = null;

    private ReactiveProperty<int> m_IntRxProperty = new ReactiveProperty<int>(9);

    void Start()
    {
        m_IntRxProperty.SubscribeToText(m_Text);

        this.UpdateAsObservable()
            .Subscribe(_ => {
                if(Input.GetMouseButtonDown(0))
                {
                    // 左键按下时,修改数据值后,查看当前文本
                    m_IntRxProperty.Value++;
                }
                if(Input.GetMouseButtonDown(1))
                {
                    // 右键按下时,修改文本后,查看当前值
                    m_Text.text = "99999";
                    Debug.Log(m_IntRxProperty.Value);

                    // 值和文本不一样,说明只是数据绑定到 UI
                }
            });
    }
}

按钮点击事件绑定

using UnityEngine;
using UnityEngine.UI;
using UniRx;

public class MyUniRx_ButtonClickBinding : MonoBehaviour
{
    [SerializeField] Button m_Button = null;

    private ReactiveProperty<int> m_IntRxProperty = new ReactiveProperty<int>(9);

    void Start()
    {
        m_Button.OnClickAsObservable().Subscribe(_ =>
        {
            Debug.Log("Click");
        });
    }
}

给按钮添加两个点击事件,能够同时响应

using UnityEngine;
using UnityEngine.UI;
using UniRx;
using UniRx.Triggers;

public class MyUniRx_ButtonClickBinding : MonoBehaviour
{
    [SerializeField] Button m_Button = null;

    private ReactiveProperty<int> m_IntRxProperty = new ReactiveProperty<int>(9);

    void Start()
    {
        m_Button.OnClickAsObservable()
            .Subscribe(_ =>
            {
                Debug.Log("Click");
            })
            .AddTo(this);

        m_Button.OnClickAsObservable()
            .Subscribe(_ =>
            {
                Debug.Log("Click 1");
            })
            .AddTo(this);
    }
}

图片拖拽事件

using UnityEngine;
using UnityEngine.UI;
using UniRx;
using UniRx.Triggers;

public class MyUniRxTest : MonoBehaviour
{
    [SerializeField] Image m_Image = null;

    void Start()
    {
        m_Image.OnBeginDragAsObservable()
            .Subscribe(_ =>
            {
                Debug.Log("BeginDrag");
            })
            .AddTo(this);
        m_Image.OnDragAsObservable()
            .Subscribe(_ =>
            {
                m_Image.transform.position = Input.mousePosition;
            })
            .AddTo(this);
        m_Image.OnEndDragAsObservable()
            .Subscribe(_ =>
            {
                Debug.Log("EndDrag");
            })
            .AddTo(this);
    }
}

Coroutine 转 Observable
using System.Collections;
using UnityEngine;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{
    void Start()
    {
        Observable.FromCoroutine(TestIEnumerator)
            .Subscribe()
            .AddTo(this);
    }

    private IEnumerator TestIEnumerator()
    {
        Debug.Log("开始");
        yield return new WaitForSeconds(1.0f);
        Debug.Log("结束");
    }
}
Observale 转 IEnumerator
using System;
using System.Collections;
using UnityEngine;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{

    void Start()
    {
        Observable.FromCoroutine(TestIEnumerator)
            .Subscribe()
            .AddTo(this);
    }

    private IEnumerator TestIEnumerator()
    {
        Debug.Log("开始");
        yield return Observable.Timer(TimeSpan.FromSeconds(1)).ToYieldInstruction();
        Debug.Log("结束");
    }
}

既然 Observable 可以转 IEnuerator,因此也就有了这样的使用方式:

using System.Collections;
using UnityEngine;
using UniRx;
using UniRx.Triggers;

public class MyUniRxTest : MonoBehaviour
{

    void Start()
    {
        Observable.FromCoroutine(TestIEnumerator)
            .Subscribe()
            .AddTo(this);
    }

    private IEnumerator TestIEnumerator()
    {
        Debug.Log("开始");
        yield return this.UpdateAsObservable().Where(_ => Input.GetMouseButtonDown(0)).First().ToYieldInstruction();
        Debug.Log("结束");
    }
}

其根本原因,还是在于 Observable 的底层实现,是 Coroutine 的这套机制;

多个任务并行

using System.Collections;
using UnityEngine;
using UniRx;
using UniRx.Triggers;

public class MyUniRxTest : MonoBehaviour
{

    void Start()
    {
        var _task1 = Observable.FromCoroutine(Task1);
        var _task2 = Observable.FromCoroutine(Task2);
        Observable.WhenAll(_task1, _task2)
            .Subscribe(_=> {
                Debug.Log("所有任务完成!");
            })
            .AddTo(this);
    }

    private IEnumerator Task1()
    {
        Debug.Log("开始 1");
        yield return this.UpdateAsObservable().Where(_ => Input.GetMouseButtonDown(0)).First().ToYieldInstruction();
        Debug.Log("结束 1");
    }

    private IEnumerator Task2()
    {
        Debug.Log("开始 2");
        yield return this.UpdateAsObservable().Where(_ => Input.GetMouseButtonDown(1)).First().ToYieldInstruction();
        Debug.Log("结束 2");
    }
}

线程

using System.Threading;
using UnityEngine;
using UniRx;

public class MyUniRxTest : MonoBehaviour
{

    void Start()
    {
        var _task1 = Observable.Start(() =>
        {
            Thread.Sleep(2);
            Debug.Log("任务 1 Sleep 2 结束");
            return 1;
        });

        var _task2 = Observable.Start(() =>
        {
            Thread.Sleep(1);
            Debug.Log("任务 2 Sleep 1 结束");
            return 2;
        });

        Observable.WhenAll(_task1, _task2).ObserveOnMainThread().Subscribe(ret =>
        {
            Debug.Log(ret[0]);
            Debug.Log(ret[1]);
        });
    }
}

从结果看,完成的顺序是 任务2 先于任务1,结果 ret 保持了 WhenAll 中的任务顺序。

MicroCoroutine
限制:
只能由 StartUpdateMicroCoroutine, StartFixedUpdateMicroCoroutine, StartEndOfFrameMicroCoroutine 这几个方法调用;
只支持 yield return null

UniRx makes it possible to implement the MVP(MVRP) Pattern.
UniRx 有助于实现 MVP 模式

ReactiveCommand

public class Player
{
    public ReactiveProperty<int> HP; 
    public ReactiveCommand Resurrect;
    public Player()
    {
        HP = new ReactiveProperty<int>(1000);
        Resurrect = HP.Select(x => x < 0).ToReactiveCommand();
        Resurrect.Subscribe(_ =>
        {
            Debug.Log("Add 2000");
            HP.Value += 2000;
        });
    }
}

public class MyUniRxTest : MonoBehaviour
{
    [SerializeField] Text m_Text = null;
    [SerializeField] Button m_Button = null;

    Player m_Player;

    void Start()
    {
        m_Player = new Player();
        m_Player.Resurrect.BindTo(m_Button);
        m_Player.HP.SubscribeToText(m_Text);

        Observable.Interval(TimeSpan.FromSeconds(1))
            .Subscribe(_ =>
            {
                m_Player.HP.Value -= 500;
            })
            .AddTo(this);
    }
}

一个 ReactiveCommand 可以绑定到一个 UGUI 按钮点击事件上
而 ReactiveCommand 本身可以通过 IObservable 对象创建,创建的过程可以附加执行的前置条件。

基于类型的订阅发布机制:MessageBroker, AsyncMessageBroker

public class TestArgs
{
    public int Value { get; set; }
}

---

// Subscribe message on global-scope.
MessageBroker.Default.Receive<TestArgs>().Subscribe(x => UnityEngine.Debug.Log(x));

// Publish message
MessageBroker.Default.Publish(new TestArgs { Value = 1000 });

那么如果存在继承关系呢?经过测试,订阅的消息,不受继承关系的影响,
AsyncMessageBroker

AsyncMessageBroker.Default.Subscribe<TestArgs>(x =>
{
    // show after 3 seconds.
    return Observable.Timer(TimeSpan.FromSeconds(3))
        .ForEachAsync(_ =>
        {
            UnityEngine.Debug.Log(x);
        });
});

AsyncMessageBroker.Default.PublishAsync(new TestArgs { Value = 3000 })
    .Subscribe(_ =>
    {
        UnityEngine.Debug.Log("called all subscriber completed");
    });

上述机制,适合建立对象的异步回收策略;

Unity-UniRx 插件 帮助在unity中更方便,快捷开发。 立即下载

相关推荐

TinaX Framework _ Unity based Game Client Framework _ 基于 Uni

TinaX Framework _ Unity based Game Client Framework _ 基于 Unity 的游戏客户端开发框架.zip

【Unity3D插件】UniRx(基于Unity的响应式编程框架)插件学习

UniRx是一种基于Unity3D的响应式编程框架。UniRx就是Unity版本的Rx响应式扩展响应式就是观察者和定时器,扩展指的是LINQ的操作符。Rx响应式扩展的特点就是擅长处理时间上的异步的逻辑。用Rx响应式扩展的方式编程可以很好地组织大量异步与并行处理。UniRx重写了.Net的响应式扩展,主要作用是解决时间上异步的逻辑,让异步逻辑变得更加简洁和优雅。Unity3D通常是单线程,但是UniRx可以让多线程更容易。UniRx可以简化 UGUI 的编程,所有的UI事件可以转化为UniRx的事件流。

qq_38721111的博客 5590

termux 安装 rockylinux

往找最新的文件目录,选择ARM版本的image。或者直接查看目录或者国内阿里云镜像,按照cpu架构(安卓9手机一般是aarch64arm最新架构),获取镜像地址,以及checksum里的SHA256信息更新到以下rocky9.sh脚本,如果不需要直接使用即可。

欢迎来到别往的博客 983

UniRx - Unity响应式编程插件

本文首发于“大话Unity”公众号。 大话Unity,让你快人几步 本文译者:郑洪智 - 你的技术探路者 翻译日期2018年2月1日 本文翻译自UniRx插件的ReadMe 这个插件是我特别喜欢的一个插件,希望能将这种技术思想传播给大家 UniRx - Unity响应式编程插件 插件作者Yoshifumi Kawai(neuecc) 本文译者:郑洪智 - 你的技术

大智_Unity探路者 2万+

Petalinux 2021.2 下 Qt组件编译报错?手把手教你修改bb文件搞定qt3d/qtquickcontrols2

本文详细解析了Petalinux 2021.2环境下Qt组件(如qt3d、qtquickcontrols2)编译报错的解决方案。通过修改bb文件或使用bbappend文件覆盖,有效解决`petalinux-build --sdk`命令执行时的源码获取失败或哈希校验不匹配问题,并提供验证与调试技巧,帮助开发者快速修复构建流程中断问题。

weixin_29188997的博客 216

echarts 生成中国陕西省份(或其他省份)的地图,大屏使用

效果图: 一、首先第一步需要下载echarts和获取到陕西身份的地图信息。 1.下载echarts链接(官网): Apache ECharts 2.生成指定省份的地图数据信息,数据可以在阿里云获取。 DataV.GeoAtlas地理小工具系列 如图,点击左圈需要的省份,这里我选择的是陕西省,然后点击右圈复制下载链接,得到一个json格式的数据,可以在json转换网站转成js格式。 Json在线解析格式化-Json在线校验Json格式化压缩-Jsons在线工具 转成js格.

PrimaryColor 3889

UniRx官方入门文档

UniRx官方入门文档;Unity中的响应式编程框架;UniRx基础教程;UniRx入门教程;UniRx初学者教程

Sun.ME的博客 1万+

kettle写doris操作

文件在目录:doris-master\extension\kettle\assemblies\plugin\target\doris-stream-loader-plugins-9.4.0.0-343.zip。官方提供了doris stream load插件,下载源码编译后放到kettle的插件目录即可使用。地址:https://github.com/apache/doris.git。注意:需要doris插件或者kettle转换生成模板的私聊博主。使用PDmaner同步业务库生成建表语句。

weixin_44449054的博客 3029

UniRx(1)——简介

目录前言响应式编程可观察序列 前言 UniRx,顾名思义就是Unity上的ReactiveX(Rx)。Unity就很好理解了,可是这个Rx又是哪路神仙?找到Rx的官方简介,大概意思是:ReactiveX是一个通过可观察序列来综合异步编程和事件编程的库。 这句话回答了很多问题:首先它是一个库,其次它的作用是简化异步编程和事件编程,使用的手段是可观察序列。 于是,我们现在已经对Rx有了一个比较模糊的认...

卐DIAX卍 1826

萤石摄像头批量下载视频后FFmepg拼接

本文描述萤石摄像头,如何批量下载视频,然后把视频片段拼接为一个完整的视频,亲测有效。有问题,可以下面留言

烤鱼哥哥的博客 1202

CANbus收发器ADM3053BRWZ-REEL7应用原理图设计

ADM3053 在 CAN 协议控制器与物理层总线之间创建一个 完全隔离的接口。该器件具有限流和热关断特性,可防止输出短路。额定温 度范围为工业温度范围,提供 20 引脚、宽体 SOIC 封装。该器件采用 5 V 单电源供电, 提供完全隔离的 CAN 解决方案。ADM3053 是一款隔离式控制器区域网络 (CAN) 物理层收 发器,集成隔离 DC/DC 转换器,符合 ISO 11898 标准。该器件采用 ADI 公司的。Coupler® 技术,将双通道隔离器、 CAN 收发器和 ADI 公司的。

zhusl6688的博客 1239

响应式编程入门教程第一节:揭秘 UniRx 核心 - ReactiveProperty - 让你的数据动起来!

本文介绍了Unity开发中的响应式编程利器UniRx及其核心组件ReactiveProperty。ReactiveProperty是一种可观察属性,能够自动通知数据变化,解决了传统事件处理方式的代码臃肿问题。它具有数据绑定自动化、泛型支持、强大订阅机制等特性,特别适用于数据驱动UI、游戏状态管理等场景。文章通过示例展示了如何使用Subscribe方法监听属性变化,并强调使用AddTo()方法管理订阅生命周期以防止内存泄漏。ReactiveProperty作为UniRx响应式系统的基础,为开发者提供了更优雅、

qq_46348216的博客 2099

Keil uVision5 STM32 startup_stm32f10x_md_vl.s error A3906U Malformed via file target not created..

🏆 本文收录于《全栈Bug调优(实战版)》专栏,致力于分享我在项目实战过程中遇到的各类Bug及其原因,并提供切实有效的解决方案。无论你是初学者还是经验丰富的开发者,本文将为你指引出一条更高效的Bug修复之路,助你早日登顶,迈向财富自由的梦想🚀!同时,欢迎大家关注、收藏、订阅本专栏,更多精彩内容正在持续更新中。让我们一起进步,Up!Up!Up!    备注: 部分问题/难题源自互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验总结所得,数条可行方案供所需之人参考。

**My Coding Family** 2773

【Unity3D插件】UniRx(基于Unity的响应式编程框架)插件教程

UniRx是一种基于Unity3D的响应式编程框架。UniRx就是Unity版本的Rx响应式扩展响应式就是观察者和定时器,扩展指的是LINQ的操作符。Rx响应式扩展的特点就是擅长处理时间上的异步的逻辑。用Rx响应式扩展的方式编程可以很好地组织大量异步与并行处理。UniRx重写了.Net的响应式扩展,主要作用是解决时间上异步的逻辑,让异步逻辑变得更加简洁和优雅。Unity3D通常是单线程,但是UniRx可以让多线程更容易。UniRx可以简化 UGUI 的编程,所有的UI事件可以转化为UniRx的事件流。

优快云博客专家,Unity3D高级软件工程师,《Unity 3D从入门到实战》作者。 4322

北斗导航 | 2023 PTTI会议论文 2023 ITM会议论文 2022 ION GNSS+ 会议论文下载:ION 美国导航学会

2023 国际技术会议(ITM) 2023 精密时间和时间间隔系统和应用会议(PTTI) 2022 美国导航学会国际会议(ION GNSS +)

尘世冰封的专栏 4612

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

UniRx 入门

UniRx是什么? UniRx (Unity响应式编程插件) 重写了.Net的响应式扩展。.Net官方的Rx很棒,但是在Unity中无法使用,并且与IOS的IL2CPP有兼容性问题。这个库这些问题并且添加了一些Unity专属的工具类。 支持的平台有:PC/Mac/Android/iOS/WP8/WindowsStore/等等,并且支持Unity4.6之后的所有版本。 UniRx 在 Unity...

什么风把您给吹来了 2546

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

02.UniRx序列(UniRx对游戏有什么用)

UniRX在游戏里面的表现呢? 学习一个技术,我们最关心的是它能不能给我们带来实际的效率,方便;做Unity的选择挺多的,大把的第三方插件;各种可视化工具,多到都不知道去挑哪一个来用;我并去推荐大家去使用什么插件,工具,这是一个双刃剑,既有方便也有不方便;方便的是你自己,痛苦的是那些不会的人和以后维护的人;插件一般使用的技术比较新,对系统有到一定的要求,因为不是自己写的东西;有可能插件出现的问题会...

Unity3d 攻城师一枚 3821

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

【插件】Unity使用UniRx

【简介】 UniRx重新实现了很多Unity的功能,比如WWW,协程,计时器,线程,双击等等,让我们变成变得轻松。 【下载】 【Unity-插件】UniRxv7.1.0Unity编程框架_unity编程-Unity3D文档类资源-优快云下载UniRx是一个Unity3D的编程框架。它专注于解决时间上异步的逻辑,使得异步逻辑的实现更加unity编程更多下载资源、学习资料请访问优快云下载频道.https://download.youkuaiyun.com/download/qq_33677553/16758396

qq_33677553的博客 1299

UniRx 资源

UniRx是什么? UniRx (Unity响应式编程插件) 重写了.Net的响应式扩展。.Net官方的Rx很棒,但是在Unity中无法使用,并且与IOS的IL2CPP有兼容性问题。这个库这些问题并且添加了一些Unity专属的工具类。 支持的平台有:PC/Mac/Android/iOS/WP8/WindowsStore/等等,并且支持Unity4.6之后的所有版本。 简介Reactive...

u012338130的专栏 472

开始学习 UniRx

UniRx 是什么 它是一个 Unity3D 的编程框架。 它还有一个名字-------------Unity响应式编程插件。它重写了.Net的响应式扩展。.Net官方的Rx非常棒,但是在Unity中无法直接使用,而且和IOS的IL2CPP有兼容性问题。但是这个库解决了这些问题并且添加了一些Unity专属的工具类。 支持的平台有:PC/Mac/Android/iOS/WP8/WindowsStor...

好的都要记下来 3661

【Unity】R3与UniRx的对比总结

介绍“UniRx”和“R3”的功能比较,R3的新功能和被废除的功能,从UniRx换成R3时的替代等。Unity中有一个名为“UniRx”的库,粗略地说,可以认为是“将UniRx按照最新的环境进行重制”。R3分为“核心模块”和“Unity插件”两部分,在Unity中运行全部功能时需要安装这两者。在R3的官方文档中记载了两者的安装方法。UniRx没有特别的最低版本,Unity 2017的相当旧的Unity版本也能运行。在Unity 2022.2以下的情况下,使用R3提供的。,可以得到相同的功能。

usering15的博客 2098

Unity性能调优手册12第三方插件:DOTween,UniRx,UniTask

本章介绍了在执行第三方库(在Unity中开发游戏时经常使用)时从性能角度考虑的一些事项

Have a nice day. 1701

【Unirx学习笔记】Dispose的使用技巧

最近在学习Unirx,发现Unirx的消息系统MessageBroker很不错。我先展示一下用法: //注册消息 MessageBroker.Default.Receive<int>(). Subscribe( ( i ) => { Debug.Log( "Count" + i ); } ); //发送消息 MessageBroker....

水鸡的游戏开发学习笔记 2501

UniWb-1- UniRx 响应式编程插件

UniRx 是什么 UniRx (Unity响应式编程插件) 重写了.Net的响应式扩展。.Net官方的Rx很棒,但是在Unity中无法使用,并且与IOS的IL2CPP有兼容性问题。这个库这些问题并且添加了一些Unity专属的工具类。 支持的平台有:PC/Mac/Android/iOS/WP8/WindowsStore/等等,并且支持Unity4.6之后的所有版本。 Un...

u012338130的专栏 348

终极UniRx插件开发指南:如何为Unity响应式编程贡献自定义扩展

UniRx是Unity平台的响应式编程框架,它将Reactive Extensions(Rx)的强大功能引入Unity开发,帮助开发者以更简洁、高效的方式处理异步操作和事件流。本文将详细介绍如何为UniRx开发自定义扩展,让你的Unity项目开发更加流畅和高效。 ## 为什么选择UniRx进行Unity开发 UniRx作为Unity平台的响应式编程框架,为开发者带来了诸多优势。它能够简化异步操

gitblog_00425的博客 972

【UniRx】Unity的UniRx框架/插件使用经验

1. 如果想监听列表中的值而不是某个属性,考虑使用ReactiveCollection2.使用已有List<int>初始化ReactiveCollection<int>,然后再改变原有List<int>的值(包括增加/修改),不会影响ReactiveCollection<int>的值3. 如果是监听了ReactiveCollection的Add事件,...

bark2003的专栏 391
上一篇: Unity 之 GameFramework
下一篇: 【Cocos Creator】【2.4】JavaScript 标准支持
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值