Beispiel #1
0
        public void Update(ref LabelUpdateStateInterop updateState, Canvas unityCanvas)
        {
            if (m_textComponent != null)
            {
                float newTextPosX = updateState.TextPosition.x - (unityCanvas.pixelRect.width / 2);
                float newTextPosY = (unityCanvas.pixelRect.height - updateState.TextPosition.y) - (unityCanvas.pixelRect.height / 2);

                newTextPosX /= unityCanvas.scaleFactor;
                newTextPosY /= unityCanvas.scaleFactor;

                m_textComponent.color = updateState.TextColor.ToColor();

                m_textComponent.rectTransform.localPosition = new Vector3(newTextPosX, newTextPosY, 0);
                m_textComponent.rectTransform.localRotation = Quaternion.Euler(0, 0, (float)updateState.TextRotationAngleDegrees);
            }

            if (m_iconComponent != null)
            {
                float newIconPosX = updateState.IconPosition.x - (unityCanvas.pixelRect.width / 2);
                float newIconPosY = (unityCanvas.pixelRect.height - updateState.IconPosition.y) - (unityCanvas.pixelRect.height / 2);

                newIconPosX /= unityCanvas.scaleFactor;
                newIconPosY /= unityCanvas.scaleFactor;

                m_iconComponent.color = updateState.IconColor.ToColor();

                m_iconComponent.rectTransform.localPosition = new Vector3(newIconPosX, newIconPosY, 0);
                m_iconComponent.rectTransform.localRotation = Quaternion.Euler(0, 0, (float)updateState.IconRotationAngleDegrees);
            }
        }
        void UpdateLabel(ref LabelUpdateStateInterop updateState)
        {
            LabelView labelView;
            var       labelID = Marshal.PtrToStringAnsi(updateState.LabelID);

            if (m_labelViews.TryGetValue(labelID, out labelView))
            {
                labelView.Update(ref updateState, m_unityCanvas);
            }
        }
        public static void UpdateLabel(IntPtr labelServiceHandle, ref LabelUpdateStateInterop updateState)
        {
            var labelService = labelServiceHandle.NativeHandleToObject <LabelServiceInternal>();

            labelService.UpdateLabel(ref updateState);
        }