示例#1
0
        private float ClampPosition(float pos, ShiftBy shiftBy)
        {
            if (pos < 0)
            {
                pos = 0;
            }
            else
            {
                switch (shiftBy)
                {
                case ShiftBy.Horizontal: { if (pos > Screen.width)
                                           {
                                               pos = Screen.width;
                                           }
                } break;

                case ShiftBy.Vertical: { if (pos > Screen.height)
                                         {
                                             pos = Screen.height;
                                         }
                } break;

                default: { throw new System.ArgumentOutOfRangeException("Действие для ShiftBy=" + shiftBy + " не описано"); }
                }
            }
            return(pos);
        }
示例#2
0
        public void SetText(string txt, float position, ShiftBy shiftBy)
        {
            if (IsCurrentExists)
            {
                textPool[current_id].text = txt;
                switch (shiftBy)
                {
                case ShiftBy.Horizontal: { textPool[current_id].rectTransform.position = new Vector2(ClampPosition(position, shiftBy), textPool[current_id].rectTransform.position.y); } break;

                case ShiftBy.Vertical: { textPool[current_id].rectTransform.position = new Vector2(textPool[current_id].rectTransform.position.x, ClampPosition(position, shiftBy)); } break;

                default: { throw new System.ArgumentOutOfRangeException("Действие для ShiftBy=" + shiftBy + " не описано"); }
                }
                current_id++;
            }
        }