Пример #1
0
    public MaterialPropertyBlock UpdateBlock()
    {
        if (_block == null)
        {
            _block = new MaterialPropertyBlock();                // make it lazy
        }
        HEX hex = _weak_hex.Target as HEX;
        Dictionary <int, int> TSet   = new Dictionary <int, int> ();
        List <Vector4>        TArray = new List <Vector4> ();

        for (int i = 0; i < spriteIds.Count; i++)
        {
            Vector4 pos = hex.GetSpritePosInfoByName(spriteIds [i]);
            TArray.Add(pos);
        }
        if (TArray.Count > 0)
        {
            _block.SetVectorArray("_ARRAY", TArray.ToArray());
        }

        _block.SetTexture("_ATLAS", hex.altasTexture);

        var mr = gameObject.GetComponent <MeshRenderer>();

        if (mr != null)
        {
            mr.SetPropertyBlock(_block);
        }

        return(_block);
    }