Beispiel #1
0
        public void Awake(InputField inputField)
        {
            _inputField = inputField;

            var parents = inputField.GetComponentsInParent <Canvas>();

            foreach (var canvas in parents)
            {
                if (canvas.CompareTag("BasicCanvas"))
                {
                    _currentCanvas = canvas.transform as RectTransform;
                }
            }
            _inputField.onEndEdit.AddListener(OnEndEdit);

            var inputfieldRectTransform = (RectTransform)_inputField.transform;
            var inputfieldHeightHalf    = inputfieldRectTransform.sizeDelta.y / 2;

            _zDepth = _currentCanvas.position.z;
            var canvasHeight = _currentCanvas.parent.GetComponent <RectTransform>().sizeDelta.y / 2f;

            _heightOffset = inputfieldHeightHalf - canvasHeight;
            _maxHeight    = canvasHeight - inputfieldRectTransform.anchoredPosition.y - inputfieldHeightHalf - 5f;
        }