void Start()
    {
        _count = _W * _H;

        _propertyBlock = new MaterialPropertyBlock();
        _matrices      = new Matrix4x4[_count];
        _data          = new DrawMeshInstancedData[_count];

        _colors  = new Vector4[_count];
        _colors2 = new Vector4[_count];

        int   idx   = 0;
        float space = 5.5f;

        for (int i = 0; i < _W; i++)
        {
            for (int j = 0; j < _H; j++)
            {
                _matrices[idx]   = Matrix4x4.identity;
                _data[idx]       = new DrawMeshInstancedData();//
                _data[idx].rot   = Quaternion.Euler(0, 180f, 0);
                _data[idx].pos.x = (float)i / (_W - 1f) * space - space * 0.5f + (j % 2) * space / (_W - 1f) * 0.5f;
                _data[idx].pos.y = 0;
                _data[idx].pos.z = (float)j / (_H - 1f) * space - space * 0.5f;
                _data[idx].scale.Set(0.1f, 0.1f, 0.1f);

                idx++;
            }
        }


        _change();
    }
Exemple #2
0
    void Start()
    {
        var m = Matrix4x4.zero;

        m[0] = 3;
        m[3] = 9;
        m[4] = 4;

        //Debug.Log(m[0]);
        //Debug.Log(m.m00);

        Debug.Log(m[3]);
        Debug.Log(m.m03);
        Debug.Log(m.m30);

        Debug.Log(m[4]);
        Debug.Log(m.m10);


        _count = _W * _H;

        _propertyBlock = new MaterialPropertyBlock();
        _matrices      = new Matrix4x4[_count];
        _data          = new DrawMeshInstancedData[_count];

        _colors1 = new Matrix4x4[_count];
        _colors2 = new Matrix4x4[_count];

        int   idx   = 0;
        float space = 5f;

        for (int i = 0; i < _W; i++)
        {
            for (int j = 0; j < _H; j++)
            {
                _matrices[idx]   = Matrix4x4.identity;
                _data[idx]       = new DrawMeshInstancedData();//
                _data[idx].rot   = Quaternion.Euler(0, 180f, 0);
                _data[idx].pos.x = (float)i / (_W - 1f) * space - space * 0.5f + (j % 2) * space / (_W - 1f) * 0.5f;
                _data[idx].pos.y = 0;
                _data[idx].pos.z = (float)j / (_H - 1f) * space - space * 0.5f;
                _data[idx].scale.Set(0.1f, 0.1f, 0.1f);

                _colors1[idx] = Matrix4x4.zero;
                _colors2[idx] = Matrix4x4.zero;

                idx++;
            }
        }


        _change();
    }