Exemplo n.º 1
0
        private void ReverseBuild()
        {
            Vector3 pos    = Vector2.zero;
            Vector3 pos1   = Vector2.zero;
            int     rCount = _renders.Count / (sprites.Count * 2);

            for (int i = 0; i < sprites.Count; i++)
            {
                SpriteRenderer sp = sprites [i];

                SpriteRenderer sr = Instantiate <SpriteRenderer>(sp);
                GameObject     ga = sr.gameObject;
                ga.name = gameObject.name + "-" + rCount + "-" + i;
                ga.transform.SetParent(transform);
                _renders.Add(sr);
                //reverse
                SpriteRenderer sr1 = Instantiate <SpriteRenderer>(sp);
                GameObject     ga1 = sr1.gameObject;
                ga1.name = gameObject.name + "-" + rCount + "-" + i + "_r";
                ga1.transform.SetParent(transform);
                _renders.Add(sr1);
                switch (direction2D)
                {
                case Direction2D.down:
                {
                    pos  = new Vector2(0, -i * _unitSize.y);
                    pos1 = new Vector2(0, -(sprites.Count + sprites.Count - i - 1) * _unitSize.y);
                    //reverse
                    Vector2DUtils.UpsideDown(sr1.transform);
                    break;
                }

                default:
                    break;
                }
                pos   = _startPos + pos;
                pos.z = transform.position.z;
                sr.transform.position = pos;
                pos1   = _startPos + pos1;
                pos1.z = transform.position.z;
                sr1.transform.position = pos1;
            }
            _preCaculateSize = _renders.Count * _unitSize;
            switch (direction2D)
            {
            case Direction2D.down:
            {
                _startPos.y = transform.position.y - _preCaculateSize.y;
                break;
            }

            default:
                break;
            }
        }