Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kayak UI 0.11
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Kayak UI 0.11
Commits
4bc68346
Unverified
Commit
4bc68346
authored
2 years ago
by
John
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #246 from StarArawn/shader-with-opacity
Shader with opacity
parents
48a90fff
fd2bf51c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/custom_shader.rs
+2
-18
2 additions, 18 deletions
examples/custom_shader.rs
examples/modal.rs
+28
-2
28 additions, 2 deletions
examples/modal.rs
with
30 additions
and
20 deletions
examples/custom_shader.rs
+
2
−
18
View file @
4bc68346
...
...
@@ -28,40 +28,24 @@ fn startup(
let
my_material
=
MyUIMaterial
{};
let
my_material_handle
=
materials
.add
(
my_material
);
let
my_material_handle1
=
my_material_handle
.clone
();
let
my_material_handle2
=
my_material_handle
.clone
();
let
mut
widget_context
=
KayakRootContext
::
new
(
camera_entity
);
widget_context
.add_plugin
(
KayakWidgetsContextPlugin
);
let
parent_id
=
None
;
rsx!
{
<
KayakAppBundle
>
<
TextWidgetBundle
styles
=
{
KStyle
{
position_type
:
KPositionType
::
SelfDirected
.into
(),
material
:
MaterialHandle
::
new
(
move
|
commands
,
entity
|
{
commands
.entity
(
entity
)
.insert
(
my_material_handle1
.clone_weak
());
})
.into
(),
..
Default
::
default
()
}}
text
=
{
TextProps
{
content
:
"Hello Shader!"
.into
(),
size
:
20.0
,
..
Default
::
default
()
}}
/>
<
TextWidgetBundle
styles
=
{
KStyle
{
position_type
:
KPositionType
::
SelfDirected
.into
(),
left
:
Units
::
Pixels
(
20.0
)
.into
(),
top
:
Units
::
Pixels
(
5.0
)
.into
(),
material
:
MaterialHandle
::
new
(
move
|
commands
,
entity
|
{
commands
.entity
(
entity
)
.insert
(
my_material_handle
2
.clone_weak
());
commands
.entity
(
entity
)
.insert
(
my_material_handle
.clone_weak
());
})
.into
(),
..
Default
::
default
()
}}
text
=
{
TextProps
{
content
:
"Hello
World
!"
.into
(),
content
:
"Hello
Shader
!"
.into
(),
size
:
20.0
,
..
Default
::
default
()
}}
...
...
This diff is collapsed.
Click to expand it.
examples/modal.rs
+
28
−
2
View file @
4bc68346
use
bevy
::
prelude
::
*
;
use
bevy
::
{
prelude
::
*
,
reflect
::
TypeUuid
,
render
::
render_resource
::
AsBindGroup
}
;
use
kayak_ui
::
prelude
::{
widgets
::
*
,
*
};
#[derive(AsBindGroup,
TypeUuid,
Debug,
Clone)]
#[uuid
=
"94c4e6f9-6f10-422c-85ec-6d582d471afc"
]
pub
struct
MyUIMaterial
{}
impl
MaterialUI
for
MyUIMaterial
{
fn
fragment_shader
()
->
bevy
::
render
::
render_resource
::
ShaderRef
{
"rainbow_shader.wgsl"
.into
()
}
}
#[derive(Component,
Default,
PartialEq,
Clone)]
struct
MyWidget
;
...
...
@@ -33,9 +42,12 @@ fn my_widget_render(
widget_context
:
Res
<
KayakWidgetContext
>
,
mut
commands
:
Commands
,
query
:
Query
<&
MyWidgetState
>
,
mut
materials
:
ResMut
<
Assets
<
MyUIMaterial
>>
,
)
->
bool
{
let
state_entity
=
widget_context
.use_state
(
&
mut
commands
,
entity
,
MyWidgetState
::
default
());
if
let
Ok
(
state
)
=
query
.get
(
state_entity
)
{
let
my_material
=
MyUIMaterial
{};
let
my_material_handle
=
materials
.add
(
my_material
);
let
parent_id
=
Some
(
entity
);
rsx!
{
<
ElementBundle
>
...
...
@@ -76,8 +88,21 @@ fn my_widget_render(
..
Default
::
default
()
}}
>
<
TextWidgetBundle
styles
=
{
KStyle
{
material
:
MaterialHandle
::
new
(
move
|
commands
,
entity
|
{
commands
.entity
(
entity
)
.insert
(
my_material_handle
.clone_weak
());
})
.into
(),
..
Default
::
default
()
}}
text
=
{
TextProps
{
content
:
"Hello Modal!"
.into
(),
size
:
20.0
,
..
Default
::
default
()
}}
/>
<
KButtonBundle
button
=
{
KButton
{
text
:
"Hide
Window
"
.into
()
}}
button
=
{
KButton
{
text
:
"Hide
Modal
"
.into
()
}}
on_event
=
{
OnEvent
::
new
(
move
|
In
(
_entity
):
In
<
Entity
>
,
mut
event
:
ResMut
<
KEvent
>
,
...
...
@@ -135,6 +160,7 @@ fn main() {
.add_plugins
(
DefaultPlugins
)
.add_plugin
(
KayakContextPlugin
)
.add_plugin
(
KayakWidgets
)
.add_plugin
(
MaterialUIPlugin
::
<
MyUIMaterial
>
::
default
())
.add_startup_system
(
startup
)
.run
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment