浏览代码

Merge pull request #285 from Unity-Technologies/zxw/fix_backdropfilter

fix typo in assertion and add a backdropfilter sample
/main
GitHub 3 年前
当前提交
147585e8
共有 3 个文件被更改,包括 80 次插入1 次删除
  1. 2
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  2. 68
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/BackdropFilterSample.cs
  3. 11
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/BackdropFilterSample.cs.meta

2
com.unity.uiwidgets/Runtime/rendering/layer.cs


Path clipPath = null,
Clip clipBehavior = Clip.antiAlias
) {
D.assert(clipPath != null);
D.assert(clipBehavior != null);
D.assert(clipBehavior != Clip.none);
_clipPath = clipPath;
_clipBehavior = clipBehavior;

68
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/BackdropFilterSample.cs


using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class BackdropFilterSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new BackdropFilterApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context)
)
);
}
}
class BackdropFilterApp : StatefulWidget {
public BackdropFilterApp(Key key = null) : base(key) {
}
public override State createState() {
return new BackdropFilterAppState();
}
}
class BackdropFilterAppState : State<BackdropFilterApp> {
public override Widget build(BuildContext context)
{
var item = new Container(
width: 350,
height: 300,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new FileImage("shrine_images/0-0.jpg"),
fit: BoxFit.cover
)
),
child: new BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5f, sigmaY: 5f),
child: new Container(
color: Colors.black.withOpacity(0.1f)
)
)
);
return new Container(color: Colors.blue, child:
new Center(
child: item
));
}
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/BackdropFilterSample.cs.meta


fileFormatVersion: 2
guid: f6b796615f43b734d8c9507513773ff3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存