您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
30 行
1.1 KiB
30 行
1.1 KiB
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using Unity.UIWidgets.engine;
|
|
using Unity.UIWidgets.widgets;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.UIWidgets.Sample.Redux.ObjectFinder {
|
|
|
|
public class GameFinderMiddleware {
|
|
public static Middleware<FinderAppState> Create() {
|
|
|
|
return (store) => (next) => (action) => {
|
|
if (action is SearchAction) {
|
|
var searchAction = (SearchAction)action;
|
|
var objects = GameObject.FindObjectsOfType(typeof(FinderGameObject)).Where((obj) => {
|
|
return searchAction.keyword == "" || obj.name.ToUpper().Contains(searchAction.keyword.ToUpper());
|
|
}).Select(obj => new GameObjectInfo{id = obj.GetInstanceID(), name=obj.name}).ToList();
|
|
|
|
var result = next(action);
|
|
store.Dispatch(new SearchResultAction() {keyword= searchAction.keyword, results= objects});
|
|
return result;
|
|
}
|
|
|
|
return next(action);
|
|
};
|
|
}
|
|
}
|
|
|
|
}
|