/// <summary> /// 移动列表使之能定位到给定数据的位置上 /// 线性插值的移动,带结束回调 /// </summary> /// <param name="obj">目标的GO</param> /// <param name="flyTime">飞行时间,负数就是直接设置过去</param> /// <param name="endCallback">结束时的回调</param> public void LocateAtTarget(GameObject obj, Single flyTime, HorizontalAlignType hAlignment = HorizontalAlignType.Left, VerticalAlignType vAlignment = VerticalAlignType.Upper, Action endCallback = null) { RefreshContentSize(); foreach (var dp in DataAndPosProviders) { if (dp.VisableGO == obj) { LocateAtTarget(dp.Index, flyTime, hAlignment, vAlignment, endCallback); break; } } }
/// <summary> /// 移动列表使之能定位到给定数据的位置上 /// 线性插值的移动,带结束回调 /// </summary> /// <param name="idx">目标index</param> /// <param name="flyTime">飞行时间,负数就是直接设置过去</param> /// <param name="endCallback">结束时的回调</param> public void LocateAtTarget(Int32 idx, Single flyTime, HorizontalAlignType hAlignment = HorizontalAlignType.Left, VerticalAlignType vAlignment = VerticalAlignType.Upper, Action endCallback = null) { if (idx < 0 || idx >= DataAndPosProviders.Count) { Debug.LogError("LocateAtTarget idx Error " + idx); return; } RefreshContentSize(); if (TweenCoroutine != null) { StopCoroutine(TweenCoroutine); TweenCoroutine = null; } var ct = content; var vt = viewport; var tarDP = DataAndPosProviders[idx]; //有负号 Vector2 tarPos = ct.anchoredPosition; Vector2 alignOffset = Vector2.zero; if (vertical) { tarPos.y = ct.rect.size.y - tarDP.Rect.position.y - tarDP.Rect.height; switch (vAlignment) { case VerticalAlignType.None: case VerticalAlignType.Upper: break; case VerticalAlignType.Lower: alignOffset.y = (tarDP.Rect.size.y - vt.rect.size.y); break; case VerticalAlignType.Middle: alignOffset.y = (tarDP.Rect.size.y - vt.rect.size.y) * 0.5f; break; default: throw new NotImplementedException("VerticalAlignType:" + vAlignment + " not Implemented"); } } if (horizontal) { tarPos.x = -tarDP.Rect.position.x; switch (hAlignment) { case HorizontalAlignType.None: case HorizontalAlignType.Left: break; case HorizontalAlignType.Right: alignOffset.x = (vt.rect.size.x - tarDP.Rect.size.x); break; case HorizontalAlignType.Center: alignOffset.x = (vt.rect.size.x - tarDP.Rect.size.x) * 0.5f; break; default: throw new NotImplementedException("HorizontalAlignType:" + hAlignment + " not Implemented"); } } tarPos += alignOffset; //三种模式下设置的目标掉不太一样 switch (movementType) { case MovementType.Unrestricted: //无限制模式目标点不做修改 break; case MovementType.Clamped: //这个需要把目标点限制在范围内 case MovementType.Elastic: //惯性模式虽然可以先弹出viewport范围,但是没什么用,修改成与Clamped模式相同 if (vertical) { tarPos.y = Mathf.Min(Mathf.Max(0, tarPos.y), Mathf.Max(ct.rect.height - vt.rect.height, 0)); //TODO现在都是左上开始排列的玩法,才能用这个0做处理 } if (horizontal) { tarPos.x = Mathf.Max(Mathf.Min(0, tarPos.x), Mathf.Min(vt.rect.width - ct.rect.width, 0)); //TODO现在都是左上开始排列的玩法,才能用这个0做处理 } break; default: Debug.LogError("new movementType found:" + movementType); break; } if (flyTime > 0) { TweenCoroutine = StartCoroutine(TweenMoveToPos(ct.anchoredPosition, tarPos, flyTime, endCallback)); } else { ct.anchoredPosition = tarPos; if (endCallback != null) { endCallback.Invoke(); } } }
/// <summary> /// 设置一个单元格的属性:大小,字体,颜色,对齐方式 /// </summary> /// <param name="wsn">工作表的名称</param> /// <param name="startRange">开始单元格</param> /// <param name="endRange">结束单元格</param> /// <param name="size">字体大小:12</param> /// <param name="name">字体名称:宋体</param> /// <param name="color">字体颜色:System.Drawing.Color.White</param> /// <param name="horizontalAlignment">文本水平对齐方式:HorizontalAlignType.Center</param> /// <param name="verticalAlignment">文本垂直对齐方式:VerticalAlignType.Center</param> /// <param name="bold">是否加粗</param> public void SetCellProperty(string wsn, string startRange, string endRange, int size, string name, System.Drawing.Color color, HorizontalAlignType horizontalAlignment, VerticalAlignType verticalAlignment, bool bold) { string range = startRange + ":" + endRange; Worksheet ws = GetSheet(wsn); CellStyle style = ws.Range[range].Style; style.Font.FontName = name; //设置字体 style.Font.Color = color; //设置字体颜色 style.Font.Size = size; //设置字体大小 style.HorizontalAlignment = horizontalAlignment; //设置文本水平对齐方式 style.VerticalAlignment = verticalAlignment; //设置文本垂直对齐方式 style.Font.IsBold = bold; }