Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Obsolete
Use OnPopulateMesh(VertexHelper vh) instead.

Graphic.OnPopulateMesh

Switch to Manual
protected void OnPopulateMesh(Mesh m);
protected void OnPopulateMesh(UI.VertexHelper vh);

Parameters

m Mesh to populate with UI data.

Description

Callback function when a UI element needs to generate vertices.

Used by Text, Image, and RawImage for example to generate vertices specific to their use case.

OnPopulateMesh is new in Unity 5.2. To upgrade code from Unity 5.1 or earlier and still using the now obsolete OnFillVBO, you can use the following glue code:

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[ExecuteInEditMode] public class ExampleClass : Graphic { protected void _OnFillVBO(List<UIVertex> vbo) { /* (5.1 code) */ }

protected override void OnPopulateMesh(Mesh m) { var vbo = new List<UIVertex>(); _OnFillVBO(vbo);

using (var vh = new VertexHelper()) { var quad = new UIVertex[4]; for (int i = 0; i < vbo.Count; i += 4) { vbo.CopyTo(i, quad, 0, 4); vh.AddUIVertexQuad(quad); } vh.FillMesh(m); } } }