private void DrawFilterEntryListElement(Rect rect, int idx, bool isactive, bool isfocused) { var gp = this.groupFilterPathDataList[idx]; //渲染数据 bool isDisable = this.incommingAssetGroup.assetGroups.ContainsKey(gp.GroupPath); EditorGUI.BeginDisabledGroup(isDisable); var output = EditorGUI.TextField(new Rect(rect.x, rect.y, rect.width, rect.height * 0.9f), gp.GroupPath); //检测改动 if (output != gp.GroupPath) { Debug.Log("改动:" + output); gp.GroupPath = output; //更新 UpdateGroupPathData(idx); var outputConnect = this.selfNodeGUI.Data.OutputPoints.Find((node) => node.Id == gp.OutputNodeId); //BDFrameworkAssetsEnv.UpdateConnectLine(this.selfNodeGUI, outputConnect); GraphNodeHelper.UpdateNodeGraph(this.selfNodeGUI); } if (isDisable) { EditorGUI.EndDisabledGroup(); } }
/// <summary> /// 刷新节点渲染 /// </summary> #endregion /// <summary> /// 预览结果 编辑器连线数据,但是build模式也会执行 /// 这里只建议设置BuildingCtx的ab颗粒度 /// </summary> /// <param name="target"></param> /// <param name="nodeData"></param> /// <param name="incoming"></param> /// <param name="connectionsToOutput"></param> /// <param name="outputFunc"></param> public override void Prepare(BuildTarget target, NodeData nodeData, IEnumerable <PerformGraph.AssetGroups> incoming, IEnumerable <ConnectionData> connectionsToOutput, PerformGraph.Output outputFunc) { Debug.Log("prepare:" + this.GetType().Name + "-" + DateTime.Now.ToLongTimeString()); if (incoming == null) { return; } this.BuildingCtx = BDFrameworkAssetsEnv.BuildingCtx; //prepare传入的资源 this.InitOutputNode(incoming); var assetsList = GraphNodeHelper.GetAllComingAssets(incoming); //初始化输出列表 var allOutMap = new Dictionary <string, List <AssetReference> >(); foreach (var group in this.groupFilterPathDataList) { if (!string.IsNullOrEmpty(group.GroupPath)) { allOutMap[group.GroupPath] = new List <AssetReference>(); } } //遍历输出 foreach (var ar in assetsList) { foreach (var gp in groupFilterPathDataList) { if (ar.importFrom.StartsWith(gp.GroupPath, StringComparison.OrdinalIgnoreCase)) { //添加 allOutMap[gp.GroupPath].Add(ar); break; } } } //每个节点输出 if (connectionsToOutput != null) { foreach (var outputNode in connectionsToOutput) { var groupFilter = this.groupFilterPathDataList.FirstOrDefault((gf) => gf.OutputNodeId == outputNode.FromNodeConnectionPointId); if (groupFilter != null) { var kv = new Dictionary <string, List <AssetReference> >() { { groupFilter.GroupPath, allOutMap[groupFilter.GroupPath] } }; outputFunc(outputNode, kv); } } } }
/// <summary> /// 移除输出节点 /// </summary> /// <param name="uIdx"></param> private void RemoveOutputNode(string uIdx) { //移除输出节点 var outputNode = this.selfNodeGUI.Data.OutputPoints.Find((node) => node.Id == uIdx); //移除数据 var gp = this.groupFilterPathDataList.Find((g) => g.OutputNodeId.Equals(uIdx)); this.groupFilterPathDataList.Remove(gp); //移除连接线 GraphNodeHelper.RemoveOutputNode(this.selfNodeGUI, outputNode); GraphNodeHelper.UpdateConnectLine(this.selfNodeGUI, outputNode); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { GUILayout.Label("初始化打包框架", EditorGUIHelper.LabelH4); this.selfNodeGUI = node; bool isDirty = false; //渲染数据. //包装一层 方便监听改动 var ret = EditorGUILayout.EnumPopup("窗口模式", (AssetGraphWindowsModeEnum)this.AssetGraphWindowsMode).GetHashCode(); if (ret != this.AssetGraphWindowsMode) { this.AssetGraphWindowsMode = ret; isDirty = true; } //根据不同的枚举进行提示 switch ((AssetGraphWindowsModeEnum)this.AssetGraphWindowsMode) { case AssetGraphWindowsModeEnum.配置节点模式: { EditorGUILayout.HelpBox("该模式下,不会加载实际Assets数据,避免卡顿!", MessageType.Info); } break; case AssetGraphWindowsModeEnum.预览节点模式: { EditorGUILayout.HelpBox("该模式下,所有操作都会预览实际Assets打包情况,比较卡!", MessageType.Info); } break; } if (GUILayout.Button("强制刷新资源数据")) { isDirty = true; GenBuildingCtx(true); } if (isDirty) { Debug.Log("更新node!"); //触发 //BDFrameworkAssetsEnv.UpdateConnectLine(this.selfNodeGUI, this.selfNodeGUI.Data.OutputPoints.FirstOrDefault()); GraphNodeHelper.UpdateNodeGraph(this.selfNodeGUI); } }
/// <summary> /// 预览结果 编辑器连线数据,但是build模式也会执行 /// 这里只建议设置BuildingCtx的ab颗粒度 /// </summary> /// <param name="target"></param> /// <param name="nodeData"></param> /// <param name="incoming"></param> /// <param name="connectionsToOutput"></param> /// <param name="outputFunc"></param> public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { // this.selfNodeGUI = node; //node.Name = EditorGUILayout.TextField("Tips:", node.Name); editor.UpdateNodeName(node); if (!node.Name.StartsWith("[颗粒度]")) { node.Name = "[颗粒度]" + node.Name; } bool isupdateNode = false; //包装一层 方便监听改动 var ret = EditorGUILayout.EnumPopup("设置规则", (FolderAssetBundleRule)this.SetAssetBundleNameRule).GetHashCode(); if (ret != this.SetAssetBundleNameRule) { this.SetAssetBundleNameRule = ret; isupdateNode = true; } //根据不同的枚举进行提示 switch ((FolderAssetBundleRule)this.SetAssetBundleNameRule) { case FolderAssetBundleRule.用该目录路径设置AB名: { EditorGUILayout.HelpBox("将该目录下所有文件,打包成一个AB!", MessageType.Info); } break; case FolderAssetBundleRule.用子目录路径设置AB名: { var label = "将该目录下所有子目录,按子目录分别打包AB! \n 如:A文件夹下有 A/a1,A/a2,A/a3三个文件夹, 则会打包为a1、a2、a3 三个AB包,\n 若存在类似A/1.txt文件, 额外会生成AssetBundle - A,包含1.txt"; EditorGUILayout.HelpBox(label, MessageType.Info); } break; } if (isupdateNode) { Debug.Log("更新node!"); //触发 //BDFrameworkAssetsEnv.UpdateConnectLine(this.selfNodeGUI, this.selfNodeGUI.Data.OutputPoints.FirstOrDefault()); GraphNodeHelper.UpdateNodeGraph(this.selfNodeGUI); } }
private void RemoveFromFilterEntryList(ReorderableList list) { if (list.count > 2) { //移除序列化值 var removeIdx = this.groupFilterPathDataList.Count - 1; var rItem = this.groupFilterPathDataList[removeIdx]; this.groupFilterPathDataList.RemoveAt(removeIdx); //移除输出节点 var rOutputNode = this.selfNodeGUI.Data.OutputPoints.Find((node) => node.Id == rItem.OutputNodeId); this.selfNodeGUI.Data.OutputPoints.Remove(rOutputNode); list.index--; //刷新 GraphNodeHelper.RemoveOutputNode(this.selfNodeGUI, rOutputNode); GraphNodeHelper.UpdateNodeGraph(this.selfNodeGUI); } }
/// <summary> /// 更新数据 /// </summary> private void AddOutputNode(string path) { var ret = this.groupFilterPathDataList.Find((g) => g.GroupPath.Equals(path)); if (ret != null) { return; } var node = this.selfNodeGUI.Data.AddOutputPoint(path); this.groupFilterPathDataList.Add(new GroupPathData() { GroupPath = path, OutputNodeId = node.Id }); GraphNodeHelper.UpdateConnectLine(this.selfNodeGUI, node); }
private void RemoveFromFilterEntryList(ReorderableList list) { if (list.count > 0) { //移除序列化值 var removeIdx = this.groupFilterPathDataList.Count - 1; var rItem = this.groupFilterPathDataList[removeIdx]; this.groupFilterPathDataList.RemoveAt(removeIdx); //移除输出节点 var rOutputNode = this.selfNodeGUI.Data.OutputPoints.Find((node) => node.Id == rItem.OutputNodeId); this.selfNodeGUI.Data.OutputPoints.Remove(rOutputNode); list.index--; //移除连接线 NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, this.selfNodeGUI, Vector2.zero, rOutputNode)); //刷新 GraphNodeHelper.UpdateNodeGraph(this.selfNodeGUI); } }