Exemplo n.º 1
0
        public void PrecalculateValues()
        {
            if (_tex == null)
            {
                return;
            }

            if (_transform == null)
            {
                return;
            }

            if (!LDtkPrefs.ShowEntityIcon)
            {
                return;
            }

            Handles.BeginGUI();
            Vector3 worldPosition = _transform.position;
            Vector3 guiPoint      = HandleUtility.WorldToGUIPointWithDepth(worldPosition);

            //if camera is in front of the point, then don't draw it
            if (guiPoint.z < 0)
            {
                return;
            }

            Vector2 guiSize = Vector2.one * HandleUtil.GetIconGUISize(worldPosition, _srcPx.size);

            _imageArea = new Rect
            {
                position = (Vector2)guiPoint - (guiSize / 2),
                size     = guiSize
            };

            _texCoords = HandleUtil.GetNormalizedTextureCoords(_tex, _srcPx);

            OffsetToNextUI = new Vector2()
            {
                x = _imageArea.x - guiPoint.x,
                y = _imageArea.height / 2 + 2
            };

            _canDraw = true;

            Handles.EndGUI();
        }