Ejemplo n.º 1
0
		public void DrawNodeCurve(UnityEngine.UI.Windows.Plugins.Flow.Data.FlowWindow from, UnityEngine.UI.Windows.Plugins.Flow.Data.FlowWindow to, bool doubleSide) {

			if (from.IsEnabled() == false || to.IsEnabled() == false) return;
			
			var fromRect = from.rect;
			Rect centerStart = fromRect;
			
			var toRect = to.rect;
			Rect centerEnd = toRect;
			
			var fromComponent = false;
			var toComponent = false;
			
			if (from.IsFunction() == true &&
			    from.IsContainer() == false) {
				
				var func = FlowSystem.GetWindow(from.GetFunctionId());
				if (func != null) {
					
					var selected = FlowSystem.GetSelected();
					var isSelected = selected.Contains(from.id) || (selected.Count == 0 && this.editor.focusedGUIWindow == from.id);
					if (isSelected == true) {
						
						var color = new Color(0f, 0f, 0f, 0.1f);
						var backColor = new Color(0.5f, 0.5f, 0.5f, 0.1f);
						
						this.DrawPolygon(new Vector3(from.rect.xMin, from.rect.yMin, 0f),
						                 new Vector3(func.rect.xMin, func.rect.yMin, 0f),
						                 new Vector3(func.rect.xMin, func.rect.yMax, 0f),
						                 new Vector3(from.rect.xMin, from.rect.yMax, 0f),
						                 backColor);
						
						this.DrawPolygon(new Vector3(from.rect.xMin, from.rect.yMin, 0f),
						                 new Vector3(func.rect.xMin, func.rect.yMin, 0f),
						                 new Vector3(func.rect.xMax, func.rect.yMin, 0f),
						                 new Vector3(from.rect.xMax, from.rect.yMin, 0f),
						                 backColor);
						
						this.DrawPolygon(new Vector3(from.rect.xMax, from.rect.yMin, 0f),
						                 new Vector3(func.rect.xMax, func.rect.yMin, 0f),
						                 new Vector3(func.rect.xMax, func.rect.yMax, 0f),
						                 new Vector3(from.rect.xMax, from.rect.yMax, 0f),
						                 backColor);
						
						this.DrawPolygon(new Vector3(from.rect.xMax, from.rect.yMax, 0f),
						                 new Vector3(func.rect.xMax, func.rect.yMax, 0f),
						                 new Vector3(func.rect.xMin, func.rect.yMax, 0f),
						                 new Vector3(from.rect.xMin, from.rect.yMax, 0f),
						                 backColor);
						
						this.DrawNodeCurveDotted(new Vector3(from.rect.xMin, from.rect.yMin, 0f),
						                         new Vector3(func.rect.xMin, func.rect.yMin, 0f),
						                         color
						                         );
						
						this.DrawNodeCurveDotted(new Vector3(from.rect.xMin, from.rect.yMax, 0f),
						                         new Vector3(func.rect.xMin, func.rect.yMax, 0f),
						                         color
						                         );
						
						this.DrawNodeCurveDotted(new Vector3(from.rect.xMax, from.rect.yMin, 0f),
						                         new Vector3(func.rect.xMax, func.rect.yMin, 0f),
						                         color
						                         );
						
						this.DrawNodeCurveDotted(new Vector3(from.rect.xMax, from.rect.yMax, 0f),
						                         new Vector3(func.rect.xMax, func.rect.yMax, 0f),
						                         color
						                         );
						
					}
					
				}
				
			}
			
			if (FlowSystem.GetData().flowWindowWithLayout == true) {
				
				var comps = from.attachedComponents.Where((c) => c.targetWindowId == to.id && c.sourceComponentTag != LayoutTag.None);
				foreach (var comp in comps) {
					
					var component = from.GetLayoutComponent(comp.sourceComponentTag);
					if (component != null) {
						
						fromRect = centerStart;
						
						var rect = component.tempEditorRect;
						fromRect = new Rect(fromRect.x + rect.x, fromRect.y + rect.y, rect.width, rect.height);
						
						this.DrawNodeCurve(from.GetContainer(), to.GetContainer(), centerStart, centerEnd, fromRect, toRect, doubleSide, 0f);
						
						fromComponent = true;
						
					}
					
				}
				
				if (doubleSide == true) {
					
					comps = to.attachedComponents.Where((c) => c.targetWindowId == from.id && c.sourceComponentTag != LayoutTag.None);
					foreach (var comp in comps) {
						
						var component = to.GetLayoutComponent(comp.sourceComponentTag);
						if (component != null) {
							
							toRect = centerEnd;
							
							var rect = component.tempEditorRect;
							toRect = new Rect(toRect.x + rect.x, toRect.y + rect.y, rect.width, rect.height);
							
							this.DrawNodeCurve(from.GetContainer(), to.GetContainer(), centerStart, centerEnd, fromRect, toRect, doubleSide, 0f);
							
							toComponent = true;
							
						}
						
					}
					
				}
				
			}
			
			if (fromComponent == false && toComponent == false) this.DrawNodeCurve(from.GetContainer(), to.GetContainer(), centerStart, centerEnd, fromRect, toRect, doubleSide);
			
		}