siyao
3 年前
当前提交
62e9f931
共有 9 个文件被更改,包括 287 次插入 和 47 次删除
-
2AwesomeUIWidgets/Assets/Packages/SGrid/codegen/TileContainerRenderObjectMixin.cs.meta
-
2AwesomeUIWidgets/Assets/Packages/SGrid/codegen/TileContainerRenderObjectMixin.mixin.gen.cs.meta
-
2AwesomeUIWidgets/Assets/Packages/SGrid/codegen/TileContainerRenderObjectMixin.mixin.njk.meta
-
130AwesomeUIWidgets/Assets/Scenes/RaycastablePickerRoom.unity
-
2AwesomeUIWidgets/Assets/Scripts/RaycastableScene/ItemPickerMainUIPanel.cs
-
29AwesomeUIWidgets/Assets/Scripts/RaycastableScene/LightController.cs
-
3AwesomeUIWidgets/Assets/Scripts/RaycastableScene/LightController.cs.meta
-
161AwesomeUIWidgets/Assets/Scripts/RaycastableScene/SceneBoard.cs
-
3AwesomeUIWidgets/Assets/Scripts/RaycastableScene/SceneBoard.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 3af8956ed28744b899a62e3b21778d83 |
|||
guid: 79ebc2e04360e6b4bb9999bb48b7bfc9 |
|||
timeCreated: 1626685582 |
|
|||
fileFormatVersion: 2 |
|||
guid: cdbbb536a55f4d5da396f06ce06aa5b8 |
|||
guid: 3d36e97708fbe5b4baa419ed53088850 |
|||
timeCreated: 1626681945 |
|
|||
using uiwidgets; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgetsSample.RaycastableScene |
|||
{ |
|||
public class LightController : MonoBehaviour |
|||
{ |
|||
public Light light; |
|||
|
|||
static Light lightInstance; |
|||
|
|||
void Start() |
|||
{ |
|||
lightInstance = light; |
|||
} |
|||
|
|||
public static void SwitchLight(bool state) |
|||
{ |
|||
lightInstance.enabled = state; |
|||
} |
|||
|
|||
public static void ChangeLightColor(float color) |
|||
{ |
|||
|
|||
lightInstance.color = Color.HSVToRGB(color, 0.3f, 0.9f); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f058ef35dcaa454b8805fb2f870ef9b5 |
|||
timeCreated: 1627451855 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.cupertino; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
|
|||
namespace UIWidgetsSample.RaycastableScene |
|||
{ |
|||
public class SceneBoard : StatefulWidget |
|||
{ |
|||
public override State createState() |
|||
{ |
|||
return new SceneBoardState(); |
|||
} |
|||
} |
|||
|
|||
public class SceneBoardState : State<SceneBoard> |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new Container( |
|||
height: 50, |
|||
color: Colors.orange, |
|||
child: new Row( |
|||
children: new List<Widget>() |
|||
{ |
|||
new ActionBox( |
|||
name: "Light", |
|||
onChange: value => |
|||
{ |
|||
Debug.Log($"input ${value}"); |
|||
LightController.SwitchLight(value); |
|||
}), |
|||
new LightSlider() |
|||
// new ColorPicker(300)
|
|||
|
|||
} |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
public class ActionBox : StatefulWidget |
|||
{ |
|||
public string name; |
|||
public Action<bool> onChange; |
|||
|
|||
public ActionBox(string name, Action<bool> onChange) |
|||
{ |
|||
this.name = name; |
|||
this.onChange = onChange; |
|||
} |
|||
|
|||
public override State createState() |
|||
{ |
|||
return new ActionBoxState(); |
|||
} |
|||
} |
|||
|
|||
public class ActionBoxState : State<ActionBox> |
|||
{ |
|||
private bool value = true; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new Row( |
|||
children: new List<Widget>() |
|||
{ |
|||
new CupertinoSwitch( |
|||
value: value, |
|||
onChanged: valueIn => |
|||
{ |
|||
setState(() => |
|||
{ |
|||
value = valueIn; |
|||
widget.onChange?.Invoke(value); |
|||
}); |
|||
} |
|||
), |
|||
new Text(widget.name) |
|||
} |
|||
); |
|||
} |
|||
} |
|||
|
|||
class LightSlider : StatefulWidget |
|||
{ |
|||
public override State createState() |
|||
{ |
|||
return new LightSliderState(); |
|||
} |
|||
} |
|||
|
|||
internal class LightSliderState : State<LightSlider> |
|||
{ |
|||
private float _currentSliderValue = 0; |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new Slider( |
|||
value: _currentSliderValue, |
|||
min: 0, |
|||
max: 1, |
|||
onChanged: (value) => { |
|||
setState(() => { |
|||
_currentSliderValue = value; |
|||
LightController.ChangeLightColor(value); |
|||
}); |
|||
} |
|||
); |
|||
} |
|||
} |
|||
|
|||
class ColorPicker : StatefulWidget { |
|||
public readonly float width; |
|||
|
|||
public ColorPicker(float width) |
|||
{ |
|||
this.width = width; |
|||
} |
|||
public override State createState() => new _ColorPickerState(); |
|||
} |
|||
class _ColorPickerState : State<ColorPicker> { |
|||
readonly List<Color> _colors = new List<Color>(){ |
|||
Color.fromARGB(255, 255, 0, 0), |
|||
Color.fromARGB(255, 255, 128, 0), |
|||
Color.fromARGB(255, 255, 255, 0), |
|||
Color.fromARGB(255, 128, 255, 0), |
|||
Color.fromARGB(255, 0, 255, 0), |
|||
Color.fromARGB(255, 0, 255, 128), |
|||
Color.fromARGB(255, 0, 255, 255), |
|||
Color.fromARGB(255, 0, 128, 255), |
|||
Color.fromARGB(255, 0, 0, 255), |
|||
Color.fromARGB(255, 127, 0, 255), |
|||
Color.fromARGB(255, 255, 0, 255), |
|||
Color.fromARGB(255, 255, 0, 127), |
|||
Color.fromARGB(255, 128, 128, 128), |
|||
}; |
|||
public override Widget build(BuildContext context) { |
|||
return new Column( |
|||
children: new List<Widget>{ |
|||
new Center( |
|||
child: new Container( |
|||
width: widget.width, |
|||
height: 15, |
|||
decoration: new BoxDecoration( |
|||
border: Border.all(width: 2, color: Colors.grey[800]), |
|||
borderRadius: BorderRadius.circular(15), |
|||
gradient: new LinearGradient(colors: _colors) |
|||
) |
|||
) |
|||
) |
|||
} |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ade70a4c7c5348c98fd35a3f70a58863 |
|||
timeCreated: 1627441794 |
撰写
预览
正在加载...
取消
保存
Reference in new issue