protected virtual void RecalculateBound() { Vector2 new_pos = GNewUITools.GetAlignedPivot(NewAlign.Left); if (IsVertical) { new_pos = GNewUITools.GetAlignedPivot(NewAlign.Top); } RectTrans.pivot = new_pos; RectTrans.anchorMax = new_pos; RectTrans.anchorMin = new_pos; _RealBound = PackBound(_ItemCount); if (_RealBound.z < 0) { _RealBound.z = RectTrans.rect.width; } if (_RealBound.w < 0) { _RealBound.w = RectTrans.rect.height; } Vector2 new_size = new Vector2(_RealBound.z, _RealBound.w); this.RectTrans.sizeDelta = GNewUITools.GetDeltaSize(RectTrans, new_size); }
private float _LastScrollRectPos; //上次记录的ScrollRectPos的位置 protected override void OnSafeInit() { base.OnSafeInit(); if (_ScrollRect == null) { _ScrollRect = GetComponent <ScrollRect>(); } _ScrollRectTrans = _ScrollRect.transform.GetComponent <RectTransform>(); _Pool = new GNewPrivatePool <GDragablePageItem>(16); _Items = new List <GDragablePageItem>(); _IsDraging = false; _IsStopMove = true; _TimeInterval = 0; _TotalTime = 0; _StartMoveTime = 0; _ItemCount = 0; _CurItemIndex = 0; _StartListenTime = 0; _ListenTimeInterval = 0.1f; _LastScrollRectPos = 0; _ScrollRect.onValueChanged.AddListener(OnScorllRectChanged); GNewUITools.SetVisible(_CellItem, false); //测试用 //SetPageItemCount(6); //_TimeInterval = 3; }
public bool IsListItemVisible(int index, float err = 1f) { if (IsInited) { RectTransform rt_v = _ScrollRect.viewport; GListItem item = GetListItem(index); if (item != null) { Rect rect_child = GNewUITools.GetRelativeRect(rt_v, item.RectTrans); Rect rect_v = rt_v.rect; if (IsVertical) { bool is_inside = rect_child.yMin + err >= rect_v.yMin && rect_child.yMax - err <= rect_v.yMax; return(is_inside); } else { bool is_inside = rect_child.xMin + err >= rect_v.xMin && rect_child.xMax - err <= rect_v.xMax; return(is_inside); } } } return(false); }
protected virtual GListItem TryCreateItem() { if (CellTemplate == null) { return(null); } GListItem rv = null; rv = _CellPool.TakeOut(); if (rv == null) { GameObject item = CUnityUtil.Instantiate(CellTemplate.gameObject) as GameObject; GListItem itemCon = GListItem.Get(item); itemCon.RectTrans.SetParent(_Content, false); rv = itemCon; if (HasChildButton && this.ClickItemButtonCallBack != null) { itemCon.OnItemClickButton = this.OnClickItemButton; } } GNewUITools.SetVisible(rv.RectTrans, true); return(rv); }
public static void EnableBlockCanvas(bool enabled) { if (Main.BlockCanvas != null) { GNewUITools.SetVisible(Main.BlockCanvas, enabled); } }
private void ApplySprite(Sprite sprite) { if (sprite == null) { return; } if (_Image == null) { _Image = GetComponent <Image>(); } if (_Image != null) { _Image.overrideSprite = sprite; if (UseNativeSize) { _Image.SetNativeSize(); } } else { Debug.LogError("This node doesnt have an Image on it! " + GNewUITools.PrintScenePath(transform)); } }
void SetAspectMode(RawImage destImage) { if (destImage == null) { destImage = _DefaluImgVideo; } GNewUITools.SetAspectMode(destImage != null ? destImage.gameObject : null, _RenderTexture.width / (float)_RenderTexture.height, (int)AspectRatioFitter.AspectMode.EnvelopeParent); }
public void SetMaskTrs(GameObject dest) { //Debug.Log ("destname="+dest.name); _CurTime = 0; _CurV4 = Vector4.zero; RectTransform rt = dest.GetComponent <RectTransform> (); RectTransform t_root = Main.UIRootCanvas as RectTransform; Rect rt_root = t_root.rect; //Vector4 v4 = t_root.InverseTransformPoint(dest.transform.position); float a = 0, b = 0, c = 0, d = 0; //float a1 = 0, c1 = 0; Rect rect = GNewUITools.GetRelativeRect(t_root, rt); a = rect.xMin / rt_root.width + 0.5f; c = 0.5f - rect.xMax / rt_root.width; b = rect.yMin / rt_root.height + 0.5f; d = 0.5f - rect.yMax / rt_root.height; //if (Util.Equals(rt.pivot.x, 0f)) //{ // a = rt.anchoredPosition.x / rt_root.width; // c = (rt_root.width - (rt.anchoredPosition.x + rt.sizeDelta.x)) / rt_root.width; //} //else if (Util.Equals(rt.pivot.x, 1f)) //{ // a = (rt_root.width + rt.anchoredPosition.x - rt.sizeDelta.x) / rt_root.width; // c = (rt_root.width - (rt_root.width + rt.anchoredPosition.x)) / rt_root.width; //} //else if (Util.Equals(rt.pivot.x, 0.5f)) //{ // a = ((rt_root.width / 2) + (rt.anchoredPosition.x - rt.sizeDelta.x / 2)) / rt_root.width; // c = (rt_root.width - ((rt_root.width / 2) + (rt.anchoredPosition.x + rt.sizeDelta.x / 2))) / rt_root.width; //} //if (Util.Equals(rt.pivot.y,0f)) { // b = rt.anchoredPosition.y / rt_root.height; // d = (rt_root.height - (rt.anchoredPosition.y + rt.sizeDelta.y)) / rt_root.height; //} else if (Util.Equals(rt.pivot.y,1f)){ // b = (rt_root.height + rt.anchoredPosition.y - rt.sizeDelta.y) / rt_root.height; // d = (rt_root.height - (rt_root.height +rt.anchoredPosition.y)) / rt_root.height; //} else if (Util.Equals(rt.pivot.y,0.5f)) { // b = ((rt_root.height / 2) + (rt.anchoredPosition.y - rt.sizeDelta.y / 2)) / rt_root.height; // d = (rt_root.height - ((rt_root.height / 2) + (rt.anchoredPosition.y + rt.sizeDelta.y / 2))) / rt_root.height; //} _TarV4 = new Vector4(a, b, c, d); if (!IsLerp) { mask.SetVector("_Rect", _TarV4); } //Debug.Log(":: " + a1 + ", " + c1); //Debug.Log("::: " + a + ", " + c); }
protected virtual void SetPivotAnchor(RectTransform rect, NewAlign align) { Vector2 new_pos = GNewUITools.GetAlignedPivot(align); rect.pivot = new_pos; rect.anchorMax = new_pos; rect.anchorMin = new_pos; }
protected GListItem TryCreateItem() { GListItem rv = null; #if IN_GAME rv = _Pool.TakeOut(); #endif if (rv == null) { RectTransform item = CUnityUtil.Instantiate(_CellRect) as RectTransform; item.SetParent(Trans, false); GListItem item_com = item.GetComponent <GListItem>(); if (item_com == null) { item_com = item.gameObject.AddComponent <GListItem>(); } //register events if (this.InitItemCallBack != null) { item_com.OnItemInit = this.OnShowItem; } if (this.ClickItemCallBack != null) { item_com.OnItemClick = this.OnClickItem; } //if (this.PressItemCallBack != null) //{ // item_com.OnItemPointerDown = this.OnPressItem; //} //if (this.ReleaseItemCallBack != null) //{ // item_com.OnItemPointerUp = this.OnReleaseItem; //} if (this.LongPressCallBack != null) { item_com.OnItemLongPress = this.OnLongPressItem; } if (HasChildButton && this.ClickItemButtonCallBack != null) { item_com.OnItemClickButton = this.OnClickItemButton; } rv = item_com; } GNewUITools.SetVisible(rv.RectTrans, true); return(rv); }
public void Event_PlayFx(string evt_name) { SafeInit(); FxEventBlock feb = FindEventBlock <FxEventBlock>(evt_name, FxEvents); if (feb != null) { GNewUITools.PlayFx(feb.Hook, feb.Anchor, null, feb.FxPath, feb.LifeTime, feb.IsUI); } }
public void ScrollToPosition(float pos) { if (IsInited) { _ScrollRect.StopMovement(); Vector2 v = _Content.anchoredPosition; v.y = GNewUITools.ClampScrollPos(pos, _Content, _ScrollRect); _Content.anchoredPosition = v; } }
public static void SetTopPatesVisible(bool enabled) { //if (TopPateCamera != null) //{ //IsTopPateVisible = is_enable; //TopPateCamera.enabled = is_enable; //} if (TopPateCanvas != null) { GNewUITools.SetVisible(TopPateCanvas, enabled); //TopPateCanvas.localScale = is_enable ? Vector3.one : Vector3.zero; } }
protected override void OnDestroy() { #if UNITY_EDITOR if (!_IsQuiting && (_ModelT != null || (_PlatformT != null && _PlatformT.childCount > 0))) { Debug.LogError("CUIMODEL destroy was not called ! " + GNewUITools.PrintScenePath(rectTransform)); LuaScriptMgr.Instance.CallOnTraceBack(); } #endif Release(); base.OnDestroy(); _IsDestroyed = true; }
protected void DisPosePageItem(List <GDragablePageItem> items, int index) { if (items.Count > index) { GDragablePageItem item = items[index]; if (item != null) { if (_Pool.PutIn(item)) { GNewUITools.SetVisible(item.RectTrans, false); } } items.RemoveAt(index); } }
protected GDragablePageItem CreateItem() { GDragablePageItem page_item = null; page_item = _Pool.TakeOut(); if (page_item == null) { RectTransform item = CUnityUtil.Instantiate(_CellItem) as RectTransform; item.SetParent(Trans, false); Vector2 new_pos = GNewUITools.GetAlignedPivot(NewAlign.Left); if (IsVertical) { new_pos = GNewUITools.GetAlignedPivot(NewAlign.Top); } item.pivot = new_pos; item.anchorMax = new_pos; item.anchorMin = new_pos; GDragablePageItem item_com = item.GetComponent <GDragablePageItem>(); if (item_com == null) { item_com = item.gameObject.AddComponent <GDragablePageItem>(); } if (this._PageItemInitCallBack != null) { item_com.OnItemInit = OnInitPageItem; } if (this._ClickPageItemCallBack != null) { item_com.OnItemClick = OnClickPageItem; } if (_HasChildButton && this._ClickPageItemButtonCallBack != null) { item_com.OnItemClickButton = this.OnClickPageItemButton; } page_item = item_com; } GNewUITools.SetVisible(page_item.RectTrans, true); return(page_item); }
protected override void OnSafeInit() { base.OnSafeInit(); if (!noScroll) { //_ScrollRect = GetComponentInParent<ScrollRect>(true); _ScrollRect = GNewUITools.SecureComponetInParent <ScrollRect>(RectTrans); } if (_ScrollRect != null) { _ScrollRect.horizontal = !IsVertical; _ScrollRect.vertical = IsVertical; } _Pool = new GNewPrivatePool <GListItem>(PoolSize); }
protected virtual void DisposeItem(List <GListItem> items, int index) { if (items.Count > 0) { GListItem item = items[items.Count - 1]; if (item != null) { if (_CellPool.PutIn(item)) { GNewUITools.SetVisible(item.RectTrans, false); } else { Destroy(item.gameObject); } } items.RemoveAt(index); } }
protected void DisposeItem(List <GListItem> items, int index) { if (items.Count > index) { GListItem item = items[index]; if (item != null) { #if IN_GAME if (_Pool.PutIn(item)) { GNewUITools.SetVisible(item.RectTrans, false); } else #endif { Destroy(item.gameObject); } } items.RemoveAt(index); } }
protected override void DisposeItem(List <GListItem> items, int index) { if (items.Count > index) { GListItem item = items[index]; if (item != null) { if (_CellPool.PutIn(item)) { GNewUITools.SetVisible(item.RectTrans, false); item.RectTrans.SetParent(poolNode, false); } else { Destroy(item.gameObject); } } items.RemoveAt(index); } }
////Adjust rect to full screen or safe area. //private void _TuneRect(GameObject target_panel, bool keep_fullScreen, Vector4 v_padding, Vector4 v_last_padding, ref Vector4 v_lastArea) //{ // //RectTransform rt_ui = target_panel.transform as RectTransform; // //RectTransform rt_p = rt_ui.parent as RectTransform; // //if (rt_p != null) // //{ // // Rect rt_pRT = GNewUITools.GetRelativeRect(ThisPanel, rt_p); // // Rect rt_sr = ThisPanel.rect; // // if (!keep_fullScreen) // // { // // Vector4 v_padding = CurSafePadding; // // rt_sr.xMin += v_padding.x; // // rt_sr.yMax -= v_padding.y; // // rt_sr.xMax -= v_padding.z; // // rt_sr.yMin += v_padding.w; // // } // // //calc the difference of parent and the screen // // Vector4 v_area = new Vector4(rt_sr.xMin - rt_pRT.xMin, rt_sr.yMax - rt_pRT.yMax, rt_sr.xMax - rt_pRT.xMax, rt_sr.yMin - rt_pRT.yMin); // // rt_ui.offsetMin += new Vector2(v_area.x, v_area.w); // // rt_ui.offsetMax += new Vector2(v_area.z, v_area.y); // //} // RectTransform rt_ui = target_panel.transform as RectTransform; // RectTransform rt_p = rt_ui.parent as RectTransform; // if (rt_p != null) // { // Vector4 v_area = Vector4.zero; // if (rt_p != ThisPanel) // { // Rect rect_sr = GNewUITools.GetRelativeRect(rt_p, ThisPanel); // Rect rect_pt = rt_p.rect; // //calc the difference of parent and the screen // v_area.Set(rect_sr.xMin - rect_pt.xMin, rect_sr.yMax - rect_pt.yMax, rect_sr.xMax - rect_pt.xMax, rect_sr.yMin - rect_pt.yMin); // } // Vector4 v_area_new = v_area; // if (!keep_fullScreen) // { // v_area_new.x += v_padding.x; // v_area_new.y -= v_padding.y; // v_area_new.z -= v_padding.z; // v_area_new.w += v_padding.w; // } // else if (rt_p != ThisPanel) // { // v_area_new -= v_lastArea; // v_lastArea = v_lastArea + v_area_new; // } // //if (rt_p != ThisPanel) // //{ // // v_areaUndo -= v_lastArea; // //} // //rt_ui.offsetMin += new Vector2(v_area.x * (rt_ui.pivot.x - rt_ui.anchorMin.x), v_area.w * (rt_ui.pivot.y - rt_ui.anchorMin.y)); // //rt_ui.offsetMax += new Vector2(v_area.z * (rt_ui.anchorMax.x - rt_ui.pivot.x), v_area.y * (rt_ui.anchorMax.y - rt_ui.pivot.y)); // Vector2 min_off = new Vector2(Mathf.Lerp(v_area_new.x, v_area_new.z, rt_ui.anchorMin.x), // Mathf.Lerp(v_area_new.w, v_area_new.y, rt_ui.anchorMin.y)); // Vector2 max_off = new Vector2(Mathf.Lerp(v_area_new.x, v_area_new.z, rt_ui.anchorMax.x), // Mathf.Lerp(v_area_new.w, v_area_new.y, rt_ui.anchorMax.y)); // rt_ui.offsetMin += min_off; // rt_ui.offsetMax += max_off; // //Check // Vector4 v_area_chk = v_area; // Vector4 v_padding_new = v_padding + v_last_padding; // if (!keep_fullScreen) // { // v_area_chk.x += v_padding_new.x; // v_area_chk.y -= v_padding_new.y; // v_area_chk.z -= v_padding_new.z; // v_area_chk.w += v_padding_new.w; // } // else if (rt_p != ThisPanel) // { // v_area_chk -= v_padding_new; // } // Vector2 min_off_2 = new Vector2(Mathf.Lerp(v_area_chk.x, v_area_chk.z, rt_ui.anchorMin.x), // Mathf.Lerp(v_area_chk.w, v_area_chk.y, rt_ui.anchorMin.y)); // Vector2 max_off_2 = new Vector2(Mathf.Lerp(v_area_chk.x, v_area_chk.z, rt_ui.anchorMax.x), // Mathf.Lerp(v_area_chk.w, v_area_chk.y, rt_ui.anchorMax.y)); // if (min_off != min_off_2 || max_off != max_off_2) // { // Common.HobaDebuger.LogError("TuneUI " + rt_ui.name + " " + min_off + ", " + max_off + " != " + min_off_2 + ", " + max_off_2); // } // } //} //Adjust rect to full screen or safe area. private void _TuneRect(InteractableUIHolder.PanelInfo p_info, Vector4 v_cur_padding, Vector4 v_last_padding) { RectTransform rt_ui = p_info.Panel.transform as RectTransform; RectTransform rt_p = rt_ui.parent as RectTransform; if (rt_p != null) { Vector4 v_padding_new = v_cur_padding; if (!p_info.IsKeptFullScreen) { Vector4 v_area_chk = Vector4.zero; v_area_chk.x += v_padding_new.x; v_area_chk.y -= v_padding_new.y; v_area_chk.z -= v_padding_new.z; v_area_chk.w += v_padding_new.w; Vector2 min_off_2 = p_info.OffsetMin + new Vector2(Mathf.Lerp(v_area_chk.x, v_area_chk.z, rt_ui.anchorMin.x), Mathf.Lerp(v_area_chk.w, v_area_chk.y, rt_ui.anchorMin.y)); Vector2 max_off_2 = p_info.OffsetMax + new Vector2(Mathf.Lerp(v_area_chk.x, v_area_chk.z, rt_ui.anchorMax.x), Mathf.Lerp(v_area_chk.w, v_area_chk.y, rt_ui.anchorMax.y)); rt_ui.offsetMin = min_off_2; rt_ui.offsetMax = max_off_2; } else if (rt_p != ThisPanel) { Rect rect_sr = GNewUITools.GetRelativeRect(rt_p, ThisPanel); Rect rect_pt = rt_p.rect; ////calc the difference of parent and the screen //v_area_chk.Set(rect_sr.xMin - rect_pt.xMin, rect_sr.yMax - rect_pt.yMax, rect_sr.xMax - rect_pt.xMax, rect_sr.yMin - rect_pt.yMin); rt_ui.anchorMin = Vector2.zero; rt_ui.anchorMax = Vector2.one; rt_ui.offsetMin = new Vector2(rect_sr.xMin - rect_pt.xMin, rect_sr.yMin - rect_pt.yMin); rt_ui.offsetMax = new Vector2(rect_sr.xMax - rect_pt.xMax, rect_sr.yMax - rect_pt.yMax); } } }
protected virtual void RecalculateBound() { if (_IsExpandItem) { if (IsVertical) { _NumberOfColumn = 1; } else { _NumberOfRow = 1; } } SetPivotAnchor(RectTrans, _Align); _RealBound = this.PackBound(this._ItemCount); if (_RealBound.z < 0) { _RealBound.z = RectTrans.rect.width; } if (_RealBound.w < 0) { _RealBound.w = RectTrans.rect.height; } //SetPivotAnchor(RectTrans, _Align); Vector2 new_size = new Vector2(_RealBound.z, _RealBound.w); this.RectTrans.sizeDelta = GNewUITools.GetDeltaSize(RectTrans, new_size); if (_LayoutElem != null) { _LayoutElem.preferredHeight = new_size.y; _LayoutElem.preferredWidth = new_size.x; _LayoutElem.enabled = false; _LayoutElem.enabled = true; } }
protected override GListItem TryCreateItem() { if (CellTemplate == null) { return(null); } GListItem rv = null; rv = _CellPool.TakeOut(); if (rv == null) { GameObject item = CUnityUtil.Instantiate(CellTemplate.gameObject) as GameObject; GListItem itemCon = GListItem.Get(item); rv = itemCon; if (HasChildButton && ClickItemButtonCallBack != null) { rv.OnItemClickButton = OnClickItemButton; } //register events if (InitItemCallBack != null) { rv.OnItemInit = OnShowItem; } if (ClickItemCallBack != null) { rv.OnItemClick = OnClickItem; } } rv.RectTrans.SetParent(_Content, false); GNewUITools.SetVisible(rv.RectTrans, true); return(rv); }
//flat means unsigned public void ScrollToPosition(float flatPos) { SafeInit(); if (_ScrollRect != null) { _ScrollRect.StopMovement(); Vector2 v = RectTrans.anchoredPosition; if (IsVertical) { //v.y = ClampScrollPos(flatPos) * DirSign; v.y = GNewUITools.ClampScrollPos(flatPos, RectTrans, _ScrollRect) * DirSign; } else { //v.x = ClampScrollPos(flatPos) * DirSign; v.x = GNewUITools.ClampScrollPos(flatPos, RectTrans, _ScrollRect) * DirSign; } RectTrans.anchoredPosition = v; } }
protected override void OnSafeInit() { base.OnSafeInit(); //RectTrans.anchorMax = RectTrans.anchorMin = RectTrans.pivot = Vector2.up; if (_CellRect == null) { if (Trans.childCount > 0) { _CellRect = Trans.GetChild(0) as RectTransform; } if (_CellRect == null) { Debug.Log("<GNewList>: Item template not found!"); } } if (_CellRect != null) { //_cellRect.gameObject.SetActive(false); GNewUITools.SetVisible(_CellRect, false); } if (_NumberOfRow < 1) { _NumberOfRow = 1; } if (_NumberOfColumn < 1) { _NumberOfColumn = 1; } if (IsAddLayoutElem) { AddLayoutElem(); } }
void PreprareRawImage(GameObject go) { if (go == null) { return; } RawImage rawImage = go.GetComponent <RawImage>(); if (rawImage != null) { rawImage.texture = _AlphaTexture; #if UNITY_IPHONE || UNITY_TVOS || UNITY_EDITOR || UNITY_STANDALONE rawImage.uvRect = new Rect(0, 1, 1, -1); //翻转 #else rawImage.uvRect = new Rect(0, 0, 1, 1); #endif } int width = _SizeMode == SizeMode.CG ? VideoSizeConfig.STANDARD_VIDEO_WIDTH : VideoSizeConfig.STANDARD_VIDEO_WIDTH_UI; int height = _SizeMode == SizeMode.CG ? VideoSizeConfig.STANDARD_VIDEO_HEIGHT : VideoSizeConfig.STANDARD_VIDEO_HEIGHT_UI; GNewUITools.SetAspectMode(go, (float)width / (float)height, (int)AspectRatioFitter.AspectMode.EnvelopeParent); }
public void SetupUISorting(int layer, int base_order) { GameObject g = gameObject; Canvas root_canv = g.GetComponent <Canvas>(); if (root_canv == null) { root_canv = g.AddComponent <Canvas>(); } GNewUITools.SetupUILayerOrder(root_canv, base_order, layer, true); if (PanelInfoList != null && PanelInfoList.Length > 0) { for (int i = 0; i < PanelInfoList.Length; i++) { GameObject g_panel = PanelInfoList[i].Panel; if (!PanelInfoList[i].DontOverrideSorting) { Canvas canv = g_panel.GetComponent <Canvas>(); if (canv == null) { canv = g_panel.AddComponent <Canvas>(); } GNewUITools.SetupUILayerOrder(canv, PanelInfoList[i].OrderOffset + base_order, layer, PanelInfoList[i].IsNeedBlockRay); } } } //UI TODO: Cache usa? UISizeAdapter usa = g.GetComponentInParent <UISizeAdapter>(); if (usa != null) { usa.Register(g); } }
public static int SetGroupToggleOn(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int)))) { var groupObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (groupObj == null) { HobaDebuger.LogWarning("SetGroupToggleOn: param 1 must be GameObject"); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } var group = groupObj.GetComponent <ToggleGroup>(); if (group == null) { HobaDebuger.LogWarning("SetGroupToggleOn: param 1 must have ToggleGroup component " + GNewUITools.PrintScenePath(groupObj.transform, 5)); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } var toggleIndex = (int)LuaScriptMgr.GetNumber(L, 2); var toggleObj = groupObj.transform.GetChild(toggleIndex - 1); //var toggleObj = LuaScriptMgr.GetUnityObject<GameObject>(L, 2); if (toggleObj == null) { HobaDebuger.LogWarning("SetGroupToggleOn: param 2 must be GameObject"); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } var toggle = toggleObj.GetComponent <Toggle>(); if (toggle == null) { HobaDebuger.LogWarning("SetGroupToggleOn: param 2 must have Toggle component " + GNewUITools.PrintScenePath(groupObj.transform, 5)); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } group.SetAllTogglesOff(); toggle.isOn = true; } else { GameUtilWrap.LogParamError("SetGroupToggleOn", count); } return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
public void Show(string text, Vector3 uipos, GBMFontAndMotionTextModel config) { //Debug.LogWarning("Show HUDText " + text + ", " + config.name + ", " + bg_type); if (!IsActive()) { gameObject.SetActive(true); } uipos += new Vector3(config._Offset.x, config._Offset.y, 0); RectTrans.localPosition = uipos; var fontScale = config._FontScale; RectTrans.localScale = Vector3.one * fontScale; Label.font = config._Font; //Label.fontSize = config._FontSize; Label.text = text; if (config._BGType > -1) { GNewUITools.SetVisible(_NodeBG, true); ImageGrpBG.SetImageIndex(config._BGType); } else { GNewUITools.SetVisible(_NodeBG, false); } if (config._MotionList != null) { for (int i = 0; i < config._MotionList.Count; i++) { if (config._MotionList[i] == null) { continue; } var motion = config._MotionList[i]; var duration = motion._Duration; var dalay = motion._Delay; var motionType = motion.GetMotionType(); if (motionType == GMotionModel.MotionType.Scale) { var model = motion as GMotionScaleModel; RectTrans.DOScale(model._Scale * Vector3.one * fontScale, duration) .SetDelay(dalay) .SetEase(model._EaseType); } else if (motionType == GMotionModel.MotionType.Linear) { var model = motion as GMotionLinearModel; RectTrans.DOMove(model.GetDest(transform.position), duration) .SetDelay(dalay) .SetEase(model._EaseType); } else if (motionType == GMotionModel.MotionType.Alpha) { var model = motion as GMotionAlphaModel; //DOTween.ToAlpha(() => Label.color, x => Label.color = x, model._Alpha, duration) // .SetDelay(dalay); DOTween.To(() => CanvasGrp.alpha, x => CanvasGrp.alpha = x, model._Alpha, duration) .SetDelay(dalay); } else if (motionType == GMotionModel.MotionType.Curve) { var model = motion as GMotionCurveModel; RectTrans.DOPath(model.GetCurvePath(transform.position), duration) .SetDelay(dalay) .SetEase(model._EaseType); } else if (motionType == GMotionModel.MotionType.ParaCurve) { var model = motion as GMotionParaCurveModel; RectTrans.DOPath(model.GetParaCurvePath(transform.position), duration) .SetDelay(dalay) .SetEase(model._EaseType); } } Invoke("OnMotionEnd", MAX_LIFT_TIME); } }
//no-base call protected override void SetPivotAnchor(RectTransform rect, NewAlign align) { if (_IsExpandItem) { if (IsVertical) { if (align == NewAlign.BottomLeft || align == NewAlign.BottomRight) { align = NewAlign.Bottom; } else if (align == NewAlign.TopLeft || align == NewAlign.TopRight) { align = NewAlign.Top; } else if (align == NewAlign.Left || align == NewAlign.Right) { align = NewAlign.Center; } } else { if (align == NewAlign.BottomLeft || align == NewAlign.TopLeft) { align = NewAlign.Left; } else if (align == NewAlign.TopRight || align == NewAlign.BottomRight) { align = NewAlign.Right; } else if (align == NewAlign.Top || align == NewAlign.Bottom) { align = NewAlign.Center; } } } if (_ScrollRect != null) { if (IsVertical) { if (align == NewAlign.BottomLeft || align == NewAlign.Left || align == NewAlign.TopLeft) { align = _IsInverseDirection ? NewAlign.TopLeft : NewAlign.BottomLeft; } else if (align == NewAlign.BottomRight || align == NewAlign.Right || align == NewAlign.TopRight) { align = _IsInverseDirection ? NewAlign.TopRight : NewAlign.BottomRight; } else { align = _IsInverseDirection ? NewAlign.Top : NewAlign.Bottom; } } else { if (align == NewAlign.BottomLeft || align == NewAlign.Bottom || align == NewAlign.BottomRight) { align = _IsInverseDirection ? NewAlign.BottomRight : NewAlign.BottomLeft; } else if (align == NewAlign.TopLeft || align == NewAlign.Top || align == NewAlign.TopRight) { align = _IsInverseDirection ? NewAlign.TopRight : NewAlign.TopLeft; } else { align = _IsInverseDirection ? NewAlign.Right : NewAlign.Left; } } } Vector2 new_pos = GNewUITools.GetAlignedPivot(align); //Vector2 new_pos_cell = CellRect.anchorMin; //if (_ScrollRect != null) //{ // if (IsVertical) // { // new_pos.y = _IsInverseDirection ? 1 : 0; // } // else // { // new_pos.x = _IsInverseDirection ? 1 : 0; // } //} CellRect.pivot = new_pos; Vector2 size = CellSize; //CellRect.anchorMax = new_pos_cell; //CellRect.anchorMin = new_pos_cell; //AdjustAnchor(CellRect, align); CellRect.anchorMax = new_pos; CellRect.anchorMin = new_pos; if (size.x > 0 && size.y > 0) { CellRect.sizeDelta = size; } rect.pivot = new_pos; //rect.anchorMax = new_pos; //rect.anchorMin = new_pos; //AdjustContentAnchor(rect, align); AdjustItemAnchor(rect); }