浏览代码

temporary fix redux issue

we need to add a host to redux widget to support multi-panel interaction. but currently the code is buggy since it only support editorwindow and will break on standalone players. we should fix this in a later PR
/uiwidgets_1.0
xingweizhu 4 年前
当前提交
ebaeb7c1
共有 1 个文件被更改,包括 19 次插入17 次删除
  1. 36
      com.unity.uiwidgets/Runtime/redux/widget_redux.cs

36
com.unity.uiwidgets/Runtime/redux/widget_redux.cs


using System;
using Unity.UIWidgets.editor;
//using Unity.UIWidgets.editor;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

public readonly bool pure;
public readonly UIWidgetsEditorWindow host;
//TODO (zxw): we should find out a better solution to support both EditorWindow and GameObject host here
//public readonly UIWidgetsEditorWindow host;
UIWidgetsEditorWindow host = null,
//UIWidgetsEditorWindow host = null,
ViewModelBuilder<ViewModel> builder = null,
StoreConverter<State, ViewModel> converter = null,
bool pure = false,

D.assert(converter != null);
this.host = host;
//this.host = host;
this.pure = pure;
this.builder = builder;
this.converter = converter;

builder: this.builder,
converter: this.converter,
pure: this.pure,
shouldRebuild: this.shouldRebuild,
host : this.host
shouldRebuild: this.shouldRebuild
//host : this.host
);
}
}

public readonly bool pure;
public readonly UIWidgetsEditorWindow host;
//public readonly UIWidgetsEditorWindow host;
public _StoreListener(
ViewModelBuilder<ViewModel> builder = null,

ShouldRebuildCallback<ViewModel> shouldRebuild = null,
UIWidgetsEditorWindow host = null,
//UIWidgetsEditorWindow host = null,
Key key = null) : base(key) {
D.assert(builder != null);
D.assert(converter != null);

this.converter = converter;
this.pure = pure;
this.shouldRebuild = shouldRebuild;
this.host = host;
//this.host = host;
}
public override widgets.State createState() {

}
void _handleStateChanged(State state) {
if (this.widget.host != null) {
var preInstance = Window.instance;
using (WindowProvider.of(this.widget.host).getScope()) {
this._innerStateChanged(state);
}
Window.instance = preInstance;
}
else if (Window.hasInstance) {
//if (this.widget.host != null) {
// var preInstance = Window.instance;
// using (WindowProvider.of(this.widget.host).getScope()) {
// this._innerStateChanged(state);
// }
// Window.instance = preInstance;
//}
if (Window.hasInstance) {
this._innerStateChanged(state);
}
else {

正在加载...
取消
保存