Created
June 27, 2016 13:09
-
-
Save baobao/41a343722b29823e08faa44587e15323 to your computer and use it in GitHub Desktop.
uGUIで動的にメッシュを描画する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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