您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.1 KiB
41 行
1.1 KiB
using UIWidgets.ui;
|
|
using UnityEngine;
|
|
|
|
namespace UIWidgets.flow {
|
|
public class PictureLayer : Layer {
|
|
private Offset _offset;
|
|
|
|
public Offset offset {
|
|
set { this._offset = value; }
|
|
}
|
|
|
|
private Picture _picture;
|
|
|
|
public Picture picture {
|
|
set { this._picture = value; }
|
|
}
|
|
|
|
public override void preroll(PrerollContext context, Matrix4x4 matrix) {
|
|
var bounds = this._picture.paintBounds.shift(this._offset);
|
|
this.paintBounds = bounds;
|
|
}
|
|
|
|
public override void paint(PaintContext context) {
|
|
var canvas = context.canvas;
|
|
|
|
if (this._offset == Offset.zero) {
|
|
canvas.drawPicture(this._picture);
|
|
return;
|
|
}
|
|
|
|
canvas.save();
|
|
try {
|
|
canvas.concat(Matrix4x4.Translate(new Vector2((float) this._offset.dx, (float) this._offset.dy)));
|
|
canvas.drawPicture(this._picture);
|
|
}
|
|
finally {
|
|
canvas.restore();
|
|
}
|
|
}
|
|
}
|
|
}
|