浏览代码

updates to SceneView Tests.

/main
kg 6 年前
当前提交
a8df55e6
共有 5 个文件被更改,包括 37 次插入93 次删除
  1. 5
      Assets/UIWidgets/Tests/Menu.cs
  2. 35
      Assets/UIWidgets/Tests/SceneViewTests.cs
  3. 8
      Assets/UIWidgets/Tests/Widgets.cs
  4. 79
      Assets/UIWidgets/Tests/ScrollViews.cs
  5. 3
      Assets/UIWidgets/Tests/ScrollViews.cs.meta

5
Assets/UIWidgets/Tests/Menu.cs


EditorWindow.GetWindow(typeof(Widgets));
}
[MenuItem("UIWidgetsTests/ScrollViews")]
public static void renderScrollViews() {
EditorWindow.GetWindow(typeof(ScrollViews));
}
[MenuItem("UIWidgetsTests/Show SceneViewTests")]
public static void showSceneView() {
SceneViewTests.show();

35
Assets/UIWidgets/Tests/SceneViewTests.cs


using System;
using System.Linq;
using System.Reflection;
using UIWidgets.editor;
using UIWidgets.painting;
using UIWidgets.rendering;

namespace UIWidgets.Tests {
public class SceneViewTests {
public static void show() {
onPreSceneGUIDelegate += OnPreSceneGUI;
SceneView.onSceneGUIDelegate += OnSceneGUI;
EditorApplication.update += Update;

}
public static void hide() {
onPreSceneGUIDelegate -= OnPreSceneGUI;
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;

[NonSerialized] private static bool hasInvoked = false;
private static EventType _lastEventType;
private static void OnPreSceneGUI(SceneView sceneView) {
_lastEventType = Event.current.rawType;
}
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
//HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
Handles.BeginGUI();
if (windowAdapter == null) {

windowAdapter.attachRootWidget(widget);
}
windowAdapter.OnGUI();
if (Event.current.type == EventType.Used) {
Event.current.type = SceneViewTests._lastEventType;
windowAdapter.OnGUI();
Event.current.type = EventType.Used;
} else {
windowAdapter.OnGUI();
}
Handles.EndGUI();
}

8
Assets/UIWidgets/Tests/Widgets.cs


Widget _buildHeader(BuildContext context) {
return new Container(
padding: EdgeInsets.only(left: 16.0, right: 8.0),
color: CLColors.blue,
// color: CLColors.blue,
height: headerHeight - _offsetY,
child: new Row(
children: new List<Widget> {

},
child: new Flexible(
child: new Container(
color: CLColors.green,
// color: CLColors.green,
child: ListView.builder(
itemCount: 20,
itemExtent: 100,

public override Widget build(BuildContext context) {
var container = new Container(
color: CLColors.background1,
// color: CLColors.background1,
color: CLColors.background1,
// color: CLColors.background1,
child: new Column(
children: new List<Widget> {
this._buildHeader(context),

79
Assets/UIWidgets/Tests/ScrollViews.cs


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)
);
}
);
}
}
}

3
Assets/UIWidgets/Tests/ScrollViews.cs.meta


fileFormatVersion: 2
guid: b14d32b9a23040969ca3316c86d899c3
timeCreated: 1537352615
正在加载...
取消
保存