gewentao
6 年前
当前提交
8a70a724
共有 25 个文件被更改,包括 725 次插入 和 193 次删除
-
11Assets/UIWidgets/Tests/Menu.cs
-
30Assets/UIWidgets/Tests/Widgets.cs
-
16Assets/UIWidgets/editor/editor_window.cs
-
19Assets/UIWidgets/foundation/diagnostics.cs
-
72Assets/UIWidgets/painting/text_painter.cs
-
23Assets/UIWidgets/painting/text_span.cs
-
24Assets/UIWidgets/painting/text_style.cs
-
30Assets/UIWidgets/rendering/editable.cs
-
23Assets/UIWidgets/service/text_input.cs
-
22Assets/UIWidgets/ui/painting/canvas_impl.cs
-
2Assets/UIWidgets/ui/painting/txt/font_manager.cs
-
13Assets/UIWidgets/ui/text.cs
-
60Assets/UIWidgets/ui/txt/paragraph.cs
-
4Assets/UIWidgets/ui/txt/word_separate.cs
-
2Assets/UIWidgets/widgets/basic.cs
-
2Assets/UIWidgets/widgets/binding.cs
-
81Assets/UIWidgets/widgets/editable_text.cs
-
55Assets/UIWidgets/widgets/framework.cs
-
2Assets/UIWidgets/widgets/sliver.cs
-
180Assets/UIWidgets/widgets/text.cs
-
4Assets/UIWidgets/widgets/text.cs.meta
-
158Assets/UIWidgets/Tests/SceneViewTests.cs
-
3Assets/UIWidgets/Tests/SceneViewTests.cs.meta
-
79Assets/UIWidgets/Tests/ScrollViews.cs
-
3Assets/UIWidgets/Tests/ScrollViews.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: f0d4b5792cbf44c4b6dd2d9c4702b178 |
|||
timeCreated: 1537816341 |
|||
guid: a0782677b6674b2fa33872f1d9bb36db |
|||
timeCreated: 1537576563 |
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using UIWidgets.editor; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.widgets; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using Color = UIWidgets.ui.Color; |
|||
|
|||
namespace UIWidgets.Tests { |
|||
public class SceneViewTests { |
|||
public static void show() { |
|||
onPreSceneGUIDelegate += OnPreSceneGUI; |
|||
SceneView.onSceneGUIDelegate += OnSceneGUI; |
|||
EditorApplication.update += Update; |
|||
|
|||
SceneView.RepaintAll(); |
|||
|
|||
_options = new Func<Widget>[] { |
|||
none, |
|||
listView, |
|||
eventsPage, |
|||
}; |
|||
_optionStrings = _options.Select(x => x.Method.Name).ToArray(); |
|||
_selected = 0; |
|||
|
|||
} |
|||
|
|||
public static void hide() { |
|||
onPreSceneGUIDelegate -= OnPreSceneGUI; |
|||
SceneView.onSceneGUIDelegate -= OnSceneGUI; |
|||
EditorApplication.update -= Update; |
|||
SceneView.RepaintAll(); |
|||
} |
|||
|
|||
public static SceneView.OnSceneFunc onPreSceneGUIDelegate { |
|||
get { |
|||
var field = typeof(SceneView).GetField("onPreSceneGUIDelegate", |
|||
BindingFlags.Static | BindingFlags.NonPublic); |
|||
|
|||
return (SceneView.OnSceneFunc) field.GetValue(null); |
|||
} |
|||
|
|||
set { |
|||
var field = typeof(SceneView).GetField("onPreSceneGUIDelegate", |
|||
BindingFlags.Static | BindingFlags.NonPublic); |
|||
|
|||
field.SetValue(null, value); |
|||
} |
|||
} |
|||
|
|||
private static Func<Widget>[] _options; |
|||
|
|||
private static string[] _optionStrings; |
|||
|
|||
private static int _selected; |
|||
|
|||
[NonSerialized] private static bool hasInvoked = false; |
|||
|
|||
private static EventType _lastEventType; |
|||
|
|||
private static void OnPreSceneGUI(SceneView sceneView) { |
|||
_lastEventType = Event.current.rawType; |
|||
} |
|||
|
|||
private static void OnSceneGUI(SceneView sceneView) { |
|||
//HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
|
|||
Handles.BeginGUI(); |
|||
|
|||
if (windowAdapter == null) { |
|||
windowAdapter = new WindowAdapter(sceneView); |
|||
} else if (windowAdapter != null && windowAdapter.editorWindow != sceneView) { |
|||
windowAdapter = new WindowAdapter(sceneView); |
|||
} |
|||
|
|||
var selected = EditorGUILayout.Popup("test case", _selected, _optionStrings); |
|||
if (selected != _selected || !hasInvoked) { |
|||
_selected = selected; |
|||
hasInvoked = true; |
|||
|
|||
var widget = _options[_selected](); |
|||
windowAdapter.attachRootWidget(widget); |
|||
} |
|||
|
|||
if (Event.current.type == EventType.Used) { |
|||
Event.current.type = SceneViewTests._lastEventType; |
|||
windowAdapter.OnGUI(); |
|||
Event.current.type = EventType.Used; |
|||
} else { |
|||
windowAdapter.OnGUI(); |
|||
} |
|||
|
|||
Handles.EndGUI(); |
|||
} |
|||
|
|||
private static void Update() { |
|||
if (windowAdapter != null) { |
|||
windowAdapter.Update(); |
|||
} |
|||
} |
|||
|
|||
private static WindowAdapter windowAdapter; |
|||
|
|||
public static Widget none() { |
|||
return null; |
|||
} |
|||
|
|||
public static Widget listView() { |
|||
return ListView.builder( |
|||
itemExtent: 20.0, |
|||
itemBuilder: (context, index) => { |
|||
return new Container( |
|||
color: Color.fromARGB(255, (index * 10) % 256, (index * 10) % 256, (index * 10) % 256) |
|||
); |
|||
} |
|||
); |
|||
} |
|||
|
|||
public static Widget eventsPage() { |
|||
return new EventsWaterfallScreen(); |
|||
} |
|||
|
|||
public static RenderBox flex() { |
|||
var flexbox = new RenderFlex( |
|||
direction: Axis.horizontal, |
|||
crossAxisAlignment: CrossAxisAlignment.center); |
|||
|
|||
flexbox.add(new RenderConstrainedBox( |
|||
additionalConstraints: new BoxConstraints(minWidth: 300, minHeight: 200), |
|||
child: new RenderDecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: new Color(0xFF00FF00) |
|||
) |
|||
))); |
|||
|
|||
flexbox.add(new RenderConstrainedBox( |
|||
additionalConstraints: new BoxConstraints(minWidth: 100, minHeight: 300), |
|||
child: new RenderDecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: new Color(0xFF00FFFF) |
|||
) |
|||
))); |
|||
|
|||
flexbox.add(new RenderConstrainedBox( |
|||
additionalConstraints: new BoxConstraints(minWidth: 50, minHeight: 100), |
|||
child: new RenderDecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: new Color(0xFF0000FF) |
|||
) |
|||
))); |
|||
|
|||
|
|||
return flexbox; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fc7ab0f913ef4bde95759153a732dbc0 |
|||
timeCreated: 1537936714 |
|
|||
using System; |
|||
using System.Linq; |
|||
using UIWidgets.editor; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.widgets; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using Color = UIWidgets.ui.Color; |
|||
|
|||
namespace UIWidgets.Tests { |
|||
public class ScrollViews : EditorWindow { |
|||
private readonly Func<Widget>[] _options; |
|||
|
|||
private readonly string[] _optionStrings; |
|||
|
|||
private int _selected; |
|||
|
|||
ScrollViews() { |
|||
this._options = new Func<Widget>[] { |
|||
this.none, |
|||
this.listView, |
|||
}; |
|||
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray(); |
|||
this._selected = 0; |
|||
|
|||
this.titleContent = new GUIContent("ScrollViews"); |
|||
} |
|||
|
|||
private WindowAdapter windowAdapter; |
|||
|
|||
[NonSerialized] private bool hasInvoked = false; |
|||
|
|||
void OnGUI() { |
|||
var selected = EditorGUILayout.Popup("test case", this._selected, this._optionStrings); |
|||
if (selected != this._selected || !this.hasInvoked) { |
|||
this._selected = selected; |
|||
this.hasInvoked = true; |
|||
|
|||
var widget = this._options[this._selected](); |
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.attachRootWidget(widget); |
|||
} |
|||
} |
|||
|
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.OnGUI(); |
|||
} |
|||
} |
|||
|
|||
void Update() { |
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.Update(); |
|||
} |
|||
} |
|||
|
|||
private void OnEnable() { |
|||
this.windowAdapter = new WindowAdapter(this); |
|||
} |
|||
|
|||
void OnDestroy() { |
|||
this.windowAdapter = null; |
|||
} |
|||
|
|||
Widget none() { |
|||
return null; |
|||
} |
|||
|
|||
Widget listView() { |
|||
return ListView.builder( |
|||
itemExtent: 20.0, |
|||
itemBuilder: (context, index) => { |
|||
return new Container( |
|||
color: Color.fromARGB(255, (index * 10) % 256, (index * 10) % 256, (index * 10) % 256) |
|||
); |
|||
} |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b14d32b9a23040969ca3316c86d899c3 |
|||
timeCreated: 1537352615 |
撰写
预览
正在加载...
取消
保存
Reference in new issue