protected R                         GetEntityRow(int num)
        {
            R rowInstance;

            int     col      = num % this._entitiesPerRow;
            int     row      = num / this._entitiesPerRow;
            Vector3 localPos = new Vector3(col * this._rowWidth, (-row) * this._rowHeight, 0);

            if (num >= this._instances.Count)
            {
                rowInstance = GoPool.Spawn(this._entityRowPrefab, this._instancesRoot.TransformPoint(localPos), this._instancesRoot.rotation, this._instancesRoot);
                rowInstance.transform.SetSiblingIndex(num);
                rowInstance.List = this;
                this._instances.Add(rowInstance);
            }
            else
            {
                rowInstance = this._instances[num];
                rowInstance.transform.localPosition = localPos;
                if (!rowInstance.gameObject.activeSelf)
                {
                    rowInstance.gameObject.SetActive(true);
                }
            }
            return(rowInstance);
        }
示例#2
0
        public TransferTween                SpawnClone(Vector2 screenPos, float depth)
        {
            Vector3 worldPosition;

            if (this.transform is RectTransform)
            {
                Vector3 canvasLocalPosition = this._cameraVar.Camera.ScreenToCanvasPoint(this._canvasVar.Canvas, screenPos);
                worldPosition = this._canvasVar.Canvas.transform.TransformPoint(canvasLocalPosition);
            }
            else
            {
                worldPosition = this._cameraVar.Camera.ScreenToWorldPoint(screenPos);
            }
            var instance = GoPool.Spawn(this,
                                        worldPosition,
                                        Quaternion.identity,
                                        this.PreferredParent);

            instance.SetDepth(depth);
            return(instance);
        }