Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

unity > mesh使ってみた

動作環境
Unity 5.3.5f1 on MacOS X El Capitan

100万個の粒子から構成される形状のビューワを作るにはどうするか。
GameObjectを100万個は出せないようだ。

パーティクルで120万個を生成している例がある。ただし、パーティクルで指定の場所に粒子を配置できるかは未消化。
http://tips.hecomi.com/entry/2016/05/08/160626

メッシュを使って、上限64Kのものをたくさん配置していることになるだろうか。

とりあえずmesh使ってみた。

参考 https://www.youtube.com/watch?v=R_kV3YiJqEw

code

using UnityEngine;
using System.Collections;

public class MeshCreateSC : MonoBehaviour {

    public float width = 50f;
    public float height = 50f;

    void Start () {
        MeshFilter mf = GetComponent<MeshFilter> ();
        Mesh mesh = new Mesh ();
        mf.mesh = mesh;

        // Vertices
        Vector3[] vertices = new Vector3[4] {
            new Vector3 (0, 0, 0), new Vector3 (width, 0, 0),
            new Vector3 (0, height, 0), new Vector3 (width, height, 0)
        };

        // Triangles
        int[] tri = new int[6];

        tri [0] = 0;
        tri [1] = 2;
        tri [2] = 1;

        tri [3] = 2;
        tri [4] = 3;
        tri [5] = 1;

        // Normals (only if you want to display object in the game).
        Vector3[] normals = new Vector3[4];

        normals [0] = -Vector3.forward;
        normals [1] = -Vector3.forward;
        normals [2] = -Vector3.forward;
        normals [3] = -Vector3.forward;

        // UVs (How textures are displayed).
        Vector2[] uv = new Vector2[4];

        uv [0] = new Vector2 (0, 0);
        uv [1] = new Vector2 (1, 0);
        uv [2] = new Vector2 (0, 1);
        uv [3] = new Vector2 (1, 1);

        // Assign Arrays
        mesh.vertices = vertices;
        mesh.triangles = tri;
        mesh.normals = normals;
        mesh.uv = uv;
    }

    // Update is called once per frame
    void Update () {

    }
}

qiita.png

qiita.png

平面を作れた。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
1
Help us understand the problem. What are the problem?