Skip to content

Instantly share code, notes, and snippets.

@baobao
Created June 27, 2016 13:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/41a343722b29823e08faa44587e15323 to your computer and use it in GitHub Desktop.
Save baobao/41a343722b29823e08faa44587e15323 to your computer and use it in GitHub Desktop.
uGUIで動的にメッシュを描画する
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class DynamicMeshWithUGUI : Graphic
{
protected override void OnPopulateMesh(VertexHelper vh)
{
// 頂点の順番
vh.AddTriangle(0,1,2);
// UIVertex:各頂点の情報
var v0 = new UIVertex();
v0.position = new Vector3(-100f, -100f);
// 修正箇所 : 色情報追加
v0.color = new Color32(255, 0, 255, 255);
var v1 = new UIVertex();
v1.position = new Vector3(0, 100f);
// 修正箇所 : 色情報追加
v1.color = new Color32(255, 255, 255, 255);
var v2 = new UIVertex();
v2.position = new Vector3(100f, -100f);
// 修正箇所 : 色情報追加
v2.color = new Color32(255, 255, 0, 255);
// 頂点情報を渡す
vh.AddVert(v0);
vh.AddVert(v1);
vh.AddVert(v2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment