public SwrveMessageRenderer(ISwrveMessageAnimator animator, SwrveMessageTextTemplatingResolver templatingResolver) { if (animator == null) { this.animator = Animator; // default back to the static setter, will be removed in 8.0 } else { this.animator = animator; } this.templatingResolver = templatingResolver; }
public void Render(float scale, int centerx, int centery, bool rotatedFormat, ISwrveMessageAnimator animator) { if (widget.Texture != null) { int textureWidth = widget.Texture.width; int textureHeight = widget.Texture.height; float computedSize = scale * widget.AnimationScale; Point centerPoint = widget.GetCenteredPosition(textureWidth, textureHeight, computedSize, scale); centerPoint.X += centerx; centerPoint.Y += centery; widget.Rect.x = centerPoint.X; widget.Rect.y = centerPoint.Y; widget.Rect.width = textureWidth * computedSize; widget.Rect.height = textureHeight * computedSize; bool pressed = false; if (isButton) { pressed = button.Pressed; if (rotatedFormat) { // Rotate 90 degrees the hit area Point widgetCenter = button.GetCenter(textureWidth, textureHeight, computedSize); button.PointerRect.x = centerx - (widget.Position.Y * scale) + widgetCenter.Y; button.PointerRect.y = centery + (widget.Position.X * scale) + widgetCenter.X; button.PointerRect.width = widget.Rect.height; button.PointerRect.height = widget.Rect.width; } else { button.PointerRect = button.Rect; } if (animator != null) { animator.AnimateButtonPressed(button); } } GUI.color = (pressed)? backgroundColor * clickTintColor : backgroundColor; GUI.DrawTexture(widget.Rect, Texture2D.whiteTexture, ScaleMode.StretchToFill, true, 0.0f); GUI.color = (pressed)? Color.white * clickTintColor : Color.white; GUI.Label(widget.Rect, content, style); } }
public void Render(float scale, int centerx, int centery, bool rotatedFormat, ISwrveMessageAnimator animator) { GUI.color = Color.white; if (image.Texture != null) { int textureWidth = image.Texture.width; int textureHeight = image.Texture.height; float computedSize = scale * image.AnimationScale; Point centerPoint = image.GetCenteredPosition(textureWidth, textureHeight, computedSize, scale); centerPoint.X += centerx; centerPoint.Y += centery; image.Rect.x = centerPoint.X; image.Rect.y = centerPoint.Y; image.Rect.width = textureWidth * computedSize; image.Rect.height = textureHeight * computedSize; GUI.DrawTexture(image.Rect, image.Texture, ScaleMode.StretchToFill, true, 0.0f); } else { GUI.Box(image.Rect, image.File); } }
public void Render(float scale, int centerx, int centery, bool rotatedFormat, ISwrveMessageAnimator animator) { if (button.Texture != null) { int textureWidth = button.Texture.width; int textureHeight = button.Texture.height; float computedSize = scale * button.AnimationScale; Point centerPoint = button.GetCenteredPosition(textureWidth, textureHeight, computedSize, scale); button.Rect.x = centerPoint.X + centerx; button.Rect.y = centerPoint.Y + centery; button.Rect.width = textureWidth * computedSize; button.Rect.height = textureHeight * computedSize; if (rotatedFormat) { // Rotate 90 degrees the hit area Point widgetCenter = button.GetCenter(textureWidth, textureHeight, computedSize); button.PointerRect.x = centerx - (button.Position.Y * scale) + widgetCenter.Y; button.PointerRect.y = centery + (button.Position.X * scale) + widgetCenter.X; button.PointerRect.width = textureHeight; button.PointerRect.height = textureWidth; } else { button.PointerRect = button.Rect; } if (animator != null) { animator.AnimateButtonPressed(button); } else { GUI.color = (button.Pressed) ? clickTintColor : Color.white; } GUI.DrawTexture(button.Rect, button.Texture, ScaleMode.StretchToFill, true, 0.0f); } else { GUI.Box(button.Rect, button.Image); } }