Git Product home page Git Product logo

hud's Introduction

本文对应的blog地址:https://huailiang.github.io/blog/2018/hud/

目前unity里UI实现一般都是通过NGUI或者uGUI。

往往使用这些的UI的时候,会带来两个缺陷:

  1. 由于层级交错导致DrawCall的升高,带来的问题就是性能的降低。

  2. 血条往往是动态的,但这些动态的东西往往会触发Lateupdate的Rebuild,从来带来一帧较大的开销,容易触发gc

这里介绍的方法是通过3D mesh的方式绘制血条,所有的HUD能够动态batch合批, 只有2个drawcall的开销。

实现方式:

代码动态创建Mesh(八个顶点,4个三角,绘制血条开销不可能再省了), Shader里采样顶点色来生成血条

字体也不再使用2d UI的Text或者UILable这样的是空间,而是3D TextMesh.

此项目采用Unity的版本Unity2017.3f1, 项目里有两个例子:

  1. HudShow 采用GUI的Slider来更新血条

  2. DCShow 通过创建大量的hud,来查看drawcall的变化

hud's People

Contributors

huailiang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.