浏览代码

test in scene view.

/main
kg 6 年前
当前提交
18998b40
共有 6 个文件被更改,包括 166 次插入16 次删除
  1. 10
      Assets/UIWidgets/Tests/Menu.cs
  2. 13
      Assets/UIWidgets/Tests/Widgets.cs
  3. 16
      Assets/UIWidgets/editor/editor_window.cs
  4. 2
      Assets/UIWidgets/widgets/binding.cs
  5. 138
      Assets/UIWidgets/Tests/SceneViewTests.cs
  6. 3
      Assets/UIWidgets/Tests/SceneViewTests.cs.meta

10
Assets/UIWidgets/Tests/Menu.cs


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

13
Assets/UIWidgets/Tests/Widgets.cs


// if local image test
if (selected == 0) {
localImagePath = EditorGUILayout.TextField(localImagePath);
if (this._selected != selected) {
this._selected = selected;
this.windowAdapter.attachRootWidget(null);

if (pixels <= headerHeight) {
setState(() => { _offsetY = pixels / 2.0; });
}
}
else {
} else {
if (_offsetY != 0.0) {
setState(() => { _offsetY = 0.0; });
}

color: CLColors.background1,
child: new Container(
color: CLColors.background1,
child: new Column(
children: new List<Widget> {
this._buildHeader(context),
child: new Column(
children: new List<Widget> {
this._buildHeader(context),
}
}
)
)
);

16
Assets/UIWidgets/editor/editor_window.cs


namespace UIWidgets.editor {
public class WindowAdapter : Window {
public WindowAdapter(EditorWindow editorWindow) {
this._editorWindow = editorWindow;
this._editorWindow.wantsMouseMove = false;
this._editorWindow.wantsMouseEnterLeaveWindow = false;
this.editorWindow = editorWindow;
this.editorWindow.wantsMouseMove = false;
this.editorWindow.wantsMouseEnterLeaveWindow = false;
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint;

}
}
readonly EditorWindow _editorWindow;
public readonly EditorWindow editorWindow;
readonly WidgetsBinding _binding;

dirty = true;
}
if (this._lastPosition != this._editorWindow.position) {
if (this._lastPosition != this.editorWindow.position) {
this._lastPosition = this._editorWindow.position;
this._lastPosition = this.editorWindow.position;
this._physicalSize = new Size(
this._lastPosition.width * EditorGUIUtility.pixelsPerPoint,
this._lastPosition.height * EditorGUIUtility.pixelsPerPoint);

}
public override void scheduleFrame() {
if (this._editorWindow != null) {
this._editorWindow.Repaint();
if (this.editorWindow != null) {
this.editorWindow.Repaint();
}
}

2
Assets/UIWidgets/widgets/binding.cs


get { return this._buildOwner; }
}
private readonly BuildOwner _buildOwner = new BuildOwner();
readonly BuildOwner _buildOwner = new BuildOwner();
public FocusManager focusManager {
get { return this._buildOwner.focusManager; }

138
Assets/UIWidgets/Tests/SceneViewTests.cs


using System;
using System.Linq;
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() {
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() {
SceneView.onSceneGUIDelegate -= OnSceneGUI;
EditorApplication.update -= Update;
SceneView.RepaintAll();
}
private static Func<Widget>[] _options;
private static string[] _optionStrings;
private static int _selected;
[NonSerialized] private static bool hasInvoked = false;
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);
}
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 Container(
color: CLColors.primary,
margin: EdgeInsets.all(50),
child:new Text(
"Today",
style: new TextStyle(
fontSize: 34,
color: CLColors.white
)
)
);
//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;
}
}
}

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


fileFormatVersion: 2
guid: fc7ab0f913ef4bde95759153a732dbc0
timeCreated: 1537936714
正在加载...
取消
保存