当前位置: 首页 > news >正文

unity Graphics的一些方法介绍

https://docs.unity3d.com/ScriptReference/Graphics.html

第一个方法:Graphics.DrawMesh
Description
draw a mesh.
DrawMesh draws a mesh for one frame. The mesh will be affected by the lights, can cast and receive shadows and be affected by Projectors - just like it was part of some game object. It can be drawn for all cameras or just for some specific camera.

Use DrawMesh in situations where you want to draw large amount of meshes, but don’t want the overhead of creating and managing game objects. Note that DrawMesh does not draw the mesh immediately; it merely “submits” it for rendering. The mesh will be rendered as part of normal rendering process. If you want to draw a mesh immediately, use Graphics.DrawMeshNow.

because DrawMesh does not draw mesh immediately, modifying material properties between calls to this function will not make the meshes pick up them. if u want to draw series of meshes with the same material, but slightly different properties (e.g. cange color of each mesh), use MaterialPropertyBlock parameter.

Note that this call will create some internal resources while the mesh is queued up for rendering. The allocation happens immediately and will be kept around until the end of frame (if the object was queued for all cameras) or until the specified camera renders itself.

举例:

using UnityEngine;

public class GraphicsDrawMeshDemo : MonoBehaviour
{
    public Camera camera1;
    public Camera camera2;
    public Mesh mesh;
    public Material material1;
    public Material material2;
    private int scale = 2;
    public void Update()
    {
        Matrix4x4 m = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one * scale);
        Graphics.DrawMesh(mesh, m, material1, 0, camera1);
        Graphics.DrawMesh(mesh, m, material2, 0, camera2);
    }
}

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

相关文章:

  • CodeForces 1151B Dima and a Bad XOR
  • unity Stopwatch
  • unity 烘焙参数的设置
  • JS 设计模式五 -- 命令模式
  • CommandBuffer实现Distort屏幕扭曲效果
  • Anti-aliasing and Continuity with Trapezoidal Shadow Maps
  • tarjan----强连通分量
  • Trapezoidal Shadow Maps (TSM) - Recipe
  • 十天冲刺-03
  • Perspective Shadow Maps: Care and Feeding
  • 网络基础 08_NAT
  • C# AttributeUsage
  • vue组件之间的传值方式
  • C# Attribute
  • linux 网络虚拟化: network namespace 简介
  • 【Linux系统编程】快速查找errno错误码信息
  • 【刷算法】求1+2+3+...+n
  • 【跃迁之路】【735天】程序员高效学习方法论探索系列(实验阶段492-2019.2.25)...
  • 0基础学习移动端适配
  • create-react-app项目添加less配置
  • css选择器
  • ES6 学习笔记(一)let,const和解构赋值
  • ES6, React, Redux, Webpack写的一个爬 GitHub 的网页
  • extjs4学习之配置
  • iOS 系统授权开发
  • JavaScript创建对象的四种方式
  • JS字符串转数字方法总结
  • uva 10370 Above Average
  • Vue学习第二天
  • 百度小程序遇到的问题
  • 更好理解的面向对象的Javascript 1 —— 动态类型和多态
  • 工程优化暨babel升级小记
  • 关于Java中分层中遇到的一些问题
  • 基于axios的vue插件,让http请求更简单
  • 基于OpenResty的Lua Web框架lor0.0.2预览版发布
  • 警报:线上事故之CountDownLatch的威力
  • 聊一聊前端的监控
  • 算法-图和图算法
  • 掌握面试——弹出框的实现(一道题中包含布局/js设计模式)
  • Prometheus VS InfluxDB
  • raise 与 raise ... from 的区别
  • 说说我为什么看好Spring Cloud Alibaba
  • ​Java并发新构件之Exchanger
  • ​LeetCode解法汇总307. 区域和检索 - 数组可修改
  • # centos7下FFmpeg环境部署记录
  • #QT项目实战(天气预报)
  • (1)Nginx简介和安装教程
  • (2)nginx 安装、启停
  • (pytorch进阶之路)CLIP模型 实现图像多模态检索任务
  • (第8天)保姆级 PL/SQL Developer 安装与配置
  • (续)使用Django搭建一个完整的项目(Centos7+Nginx)
  • (转)memcache、redis缓存
  • (转)PlayerPrefs在Windows下存到哪里去了?
  • (转载)从 Java 代码到 Java 堆
  • (轉貼)《OOD启思录》:61条面向对象设计的经验原则 (OO)