void Start() { sprite = GetComponent<UIBasicSprite>(); spriteRenderer = GetComponent<SpriteRenderer>(); if(sprite != null) sprite.color = colors[0]; else spriteRenderer.color = colors[0]; currentColor = 1; }
static int set_centerType(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; UIBasicSprite.AdvancedType arg0 = (UIBasicSprite.AdvancedType)ToLua.CheckObject(L, 2, typeof(UIBasicSprite.AdvancedType)); obj.centerType = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index centerType on a nil value" : e.Message)); } }
static int get_topType(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; UIBasicSprite.AdvancedType ret = obj.topType; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index topType on a nil value" : e.Message)); } }
static int get_fillAmount(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; float ret = obj.fillAmount; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index fillAmount on a nil value")); } }
static int get_fillDirection(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; UIBasicSprite.FillDirection ret = obj.fillDirection; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index fillDirection on a nil value" : e.Message)); } }
static int get_flip(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; UIBasicSprite.Flip ret = obj.flip; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index flip on a nil value")); } }
static int set_flip(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; UIBasicSprite.Flip arg0 = (UIBasicSprite.Flip)ToLua.CheckObject(L, 2, typeof(UIBasicSprite.Flip)); obj.flip = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index flip on a nil value" : e.Message)); } }
static int get_hasBorder(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; bool ret = obj.hasBorder; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index hasBorder on a nil value")); } }
static int get_premultipliedAlpha(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; bool ret = obj.premultipliedAlpha; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index premultipliedAlpha on a nil value" : e.Message)); } }
static int set_fillDirection(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; UIBasicSprite.FillDirection arg0 = (UIBasicSprite.FillDirection)ToLua.CheckObject(L, 2, typeof(UIBasicSprite.FillDirection)); obj.fillDirection = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index fillDirection on a nil value")); } }
static int set_fillAmount(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.fillAmount = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index fillAmount on a nil value")); } }
static int get_pixelSize(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; float ret = obj.pixelSize; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index pixelSize on a nil value" : e.Message)); } }
static int get_minHeight(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; int ret = obj.minHeight; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index minHeight on a nil value" : e.Message)); } }
static int set_invert(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.invert = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index invert on a nil value")); } }
/// <summary> /// Helper function that adds the specified values to the buffers. /// </summary> static void Fill(UIBasicSprite obj, BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color> cols, float v0x, float v1x, float v0y, float v1y, float u0x, float u1x, float u0y, float u1y, Color col) { verts.Add(obj.CreateVertexPos(v0x, v0y)); verts.Add(obj.CreateVertexPos(v0x, v1y)); verts.Add(obj.CreateVertexPos(v1x, v1y)); verts.Add(obj.CreateVertexPos(v1x, v0y)); uvs.Add(new Vector2(u0x, u0y)); uvs.Add(new Vector2(u0x, u1y)); uvs.Add(new Vector2(u1x, u1y)); uvs.Add(new Vector2(u1x, u0y)); cols.Add(col); cols.Add(col); cols.Add(col); cols.Add(col); }
private static int get_fillDirection(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; UIBasicSprite.FillDirection fillDirection = uIBasicSprite.fillDirection; ToLua.Push(L, fillDirection); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index fillDirection on a nil value"); } return(result); }
private static int set_fillAmount(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; float fillAmount = (float)LuaDLL.luaL_checknumber(L, 2); uIBasicSprite.fillAmount = fillAmount; result = 0; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index fillAmount on a nil value"); } return(result); }
private static int get_hasBorder(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; bool hasBorder = uIBasicSprite.hasBorder; LuaDLL.lua_pushboolean(L, hasBorder); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index hasBorder on a nil value"); } return(result); }
private static int get_minHeight(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; int minHeight = uIBasicSprite.minHeight; LuaDLL.lua_pushinteger(L, minHeight); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index minHeight on a nil value"); } return(result); }
private static int get_premultipliedAlpha(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; bool premultipliedAlpha = uIBasicSprite.premultipliedAlpha; LuaDLL.lua_pushboolean(L, premultipliedAlpha); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index premultipliedAlpha on a nil value"); } return(result); }
private static int get_pixelSize(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; float pixelSize = uIBasicSprite.pixelSize; LuaDLL.lua_pushnumber(L, (double)pixelSize); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index pixelSize on a nil value"); } return(result); }
private static int set_topType(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; UIBasicSprite.AdvancedType topType = (UIBasicSprite.AdvancedType)((int)ToLua.CheckObject(L, 2, typeof(UIBasicSprite.AdvancedType))); uIBasicSprite.topType = topType; result = 0; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index topType on a nil value"); } return(result); }
private static int get_rightType(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; UIBasicSprite.AdvancedType rightType = uIBasicSprite.rightType; ToLua.Push(L, rightType); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index rightType on a nil value"); } return(result); }
public static void SetColor(Component comp, Color color) { if (IsTargetNotNull(comp)) { UIBasicSprite basicSprite = comp.GetComp <UIBasicSprite>(); if (basicSprite) { basicSprite.color = color; return; } UILabel label = comp.GetComp <UILabel>(); if (label) { label.color = color; return; } Debugger.LogError("Can't find sprite or label!", comp); } }
private static int set_fillDirection(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; UIBasicSprite.FillDirection fillDirection = (UIBasicSprite.FillDirection)((int)ToLua.CheckObject(L, 2, typeof(UIBasicSprite.FillDirection))); uIBasicSprite.fillDirection = fillDirection; result = 0; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index fillDirection on a nil value"); } return(result); }
private static int set_invert(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIBasicSprite uIBasicSprite = (UIBasicSprite)obj; bool invert = LuaDLL.luaL_checkboolean(L, 2); uIBasicSprite.invert = invert; result = 0; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index invert on a nil value"); } return(result); }
/// <summary> /// Manually close the popup list. /// </summary> public virtual void CloseSelf() { if (mChild != null && current == this) { StopCoroutine("CloseIfUnselected"); mSelection = null; mLabelList.Clear(); if (isAnimated) { UIWidget[] widgets = mChild.GetComponentsInChildren <UIWidget>(); for (int i = 0, imax = widgets.Length; i < imax; ++i) { UIWidget w = widgets[i]; Color c = w.color; c.a = 0f; TweenColor.Begin(w.gameObject, animSpeed, c).method = UITweener.Method.EaseOut; } Collider[] cols = mChild.GetComponentsInChildren <Collider>(); for (int i = 0, imax = cols.Length; i < imax; ++i) { cols[i].enabled = false; } Destroy(mChild, animSpeed); mFadeOutComplete = Time.unscaledTime + Mathf.Max(0.1f, animSpeed); } else { Destroy(mChild); mFadeOutComplete = Time.unscaledTime + 0.1f; } mBackground = null; mHighlight = null; mChild = null; current = null; } }
public virtual void CloseSelf() { if (UIPopupList.mChild != null && UIPopupList.current == this) { base.StopCoroutine("CloseIfUnselected"); this.mSelection = null; this.mLabelList.Clear(); if (this.isAnimated) { UIWidget[] componentsInChildren = UIPopupList.mChild.GetComponentsInChildren <UIWidget>(); int i = 0; int num = componentsInChildren.Length; while (i < num) { UIWidget uIWidget = componentsInChildren[i]; Color color = uIWidget.color; color.a = 0f; TweenColor.Begin(uIWidget.gameObject, 0.15f, color).method = UITweener.Method.EaseOut; i++; } Collider[] componentsInChildren2 = UIPopupList.mChild.GetComponentsInChildren <Collider>(); int j = 0; int num2 = componentsInChildren2.Length; while (j < num2) { componentsInChildren2[j].enabled = false; j++; } UnityEngine.Object.Destroy(UIPopupList.mChild, 0.15f); UIPopupList.mFadeOutComplete = Time.unscaledTime + Mathf.Max(0.1f, 0.15f); } else { UnityEngine.Object.Destroy(UIPopupList.mChild); UIPopupList.mFadeOutComplete = Time.unscaledTime + 0.1f; } this.mBackground = null; this.mHighlight = null; UIPopupList.mChild = null; UIPopupList.current = null; } }
public void MaskFadeExpanding(float size, float time, bool isWhite = true) { init(); maskTex.enabled = true; if (!isWhite) { UIBasicSprite uIBasicSprite = maskTex; Color color = parentTex.color; float r = color.r; Color color2 = parentTex.color; float g = color2.g; Color color3 = parentTex.color; uIBasicSprite.color = new Color(r, g, color3.b, 1f); } else { maskTex.color = Color.white; } TweenScale.Begin(base.gameObject, time, new Vector3(size, size, 1f)); TweenAlpha.Begin(base.gameObject, time, 0f); }
private void Start() { parentTex = ((Component)base.transform.parent).GetComponent <UIBasicSprite>(); if ((bool)parentTex.gameObject.GetComponent <UITexture>()) { maskTex = base.transform.AddComponent <UITexture>(); maskTex.mainTexture = parentTex.mainTexture; maskTex.width = parentTex.width; maskTex.height = parentTex.height; maskTex.shader = Shader.Find("GUI/Text Shader"); } else { maskTex = base.transform.AddComponent <UISprite>(); ((UISprite)maskTex).atlas = ((UISprite)parentTex).atlas; ((UISprite)maskTex).spriteName = ((UISprite)parentTex).spriteName; maskTex.width = parentTex.width; maskTex.height = parentTex.height; } maskTex.enabled = false; maskTex.depth = 100; }
static int get_leftType(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); UIBasicSprite obj = (UIBasicSprite)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name leftType"); } else { LuaDLL.luaL_error(L, "attempt to index leftType on a nil value"); } } LuaScriptMgr.Push(L, obj.leftType); return(1); }
private static IEnumerator FadeOut(UIBasicSprite sprite, float time) { while(sprite.alpha > 0) { sprite.alpha -= Time.deltaTime / time; yield return null; } sprite.enabled = false; sprite.alpha = 1; }
void Start () { mBar = GetComponent<UIProgressBar>(); mSprite = GetComponent<UIBasicSprite>(); Update(); }
/// <summary> /// Show the popup list dialog. /// </summary> public virtual void Show () { if (enabled && NGUITools.GetActive(gameObject) && mChild == null && isValid && items.Count > 0) { mLabelList.Clear(); StopCoroutine("CloseIfUnselected"); // Ensure the popup's source has the selection UICamera.selectedObject = (UICamera.hoveredObject ?? gameObject); mSelection = UICamera.selectedObject; source = UICamera.selectedObject; if (source == null) { Debug.LogError("Popup list needs a source object..."); return; } mOpenFrame = Time.frameCount; // Automatically locate the panel responsible for this object if (mPanel == null) { mPanel = UIPanel.Find(transform); if (mPanel == null) return; } // Calculate the dimensions of the object triggering the popup list so we can position it below it Vector3 min; Vector3 max; // Create the root object for the list mChild = new GameObject("Drop-down List"); mChild.layer = gameObject.layer; if (separatePanel) { if (GetComponent<Collider>() != null) { Rigidbody rb = mChild.AddComponent<Rigidbody>(); rb.isKinematic = true; } else if (GetComponent<Collider2D>() != null) { Rigidbody2D rb = mChild.AddComponent<Rigidbody2D>(); rb.isKinematic = true; } mChild.AddComponent<UIPanel>().depth = 1000000; } current = this; Transform t = mChild.transform; t.parent = mPanel.cachedTransform; // Manually triggered popup list on some other game object if (openOn == OpenOn.Manual && mSelection != gameObject) { startingPosition = UICamera.lastEventPosition; min = mPanel.cachedTransform.InverseTransformPoint(mPanel.anchorCamera.ScreenToWorldPoint(startingPosition)); max = min; t.localPosition = min; startingPosition = t.position; } else { Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(mPanel.cachedTransform, transform, false, false); min = bounds.min; max = bounds.max; t.localPosition = min; startingPosition = t.position; } StartCoroutine("CloseIfUnselected"); t.localRotation = Quaternion.identity; t.localScale = Vector3.one; int depth = separatePanel ? 0 : NGUITools.CalculateNextDepth(mPanel.gameObject); // Add a sprite for the background if (background2DSprite != null) { UI2DSprite sp2 = mChild.AddWidget<UI2DSprite>(depth); sp2.sprite2D = background2DSprite; mBackground = sp2; } else if (atlas != null) mBackground = NGUITools.AddSprite(mChild, atlas, backgroundSprite, depth); else return; bool placeAbove = (position == Position.Above); if (position == Position.Auto) { UICamera cam = UICamera.FindCameraForLayer(mSelection.layer); if (cam != null) { Vector3 viewPos = cam.cachedCamera.WorldToViewportPoint(startingPosition); placeAbove = (viewPos.y < 0.5f); } } mBackground.pivot = UIWidget.Pivot.TopLeft; mBackground.color = backgroundColor; // We need to know the size of the background sprite for padding purposes Vector4 bgPadding = mBackground.border; mBgBorder = bgPadding.y; mBackground.cachedTransform.localPosition = new Vector3(0f, placeAbove ? bgPadding.y * 2f - overlap : overlap, 0f); // Add a sprite used for the selection if (highlight2DSprite != null) { UI2DSprite sp2 = mChild.AddWidget<UI2DSprite>(++depth); sp2.sprite2D = highlight2DSprite; mHighlight = sp2; } else if (atlas != null) mHighlight = NGUITools.AddSprite(mChild, atlas, highlightSprite, ++depth); else return; float hlspHeight = 0f, hlspLeft = 0f; if (mHighlight.hasBorder) { hlspHeight = mHighlight.border.w; hlspLeft = mHighlight.border.x; } mHighlight.pivot = UIWidget.Pivot.TopLeft; mHighlight.color = highlightColor; float fontHeight = activeFontSize; float dynScale = activeFontScale; float labelHeight = fontHeight * dynScale; float lineHeight = labelHeight + padding.y; float x = 0f, y = placeAbove ? bgPadding.y - padding.y - overlap : -padding.y - bgPadding.y + overlap; float contentHeight = bgPadding.y * 2f + padding.y; List<UILabel> labels = new List<UILabel>(); // Clear the selection if it's no longer present if (!items.Contains(mSelectedItem)) mSelectedItem = null; // Run through all items and create labels for each one for (int i = 0, imax = items.Count; i < imax; ++i) { string s = items[i]; UILabel lbl = NGUITools.AddWidget<UILabel>(mChild, mBackground.depth + 2); lbl.name = i.ToString(); lbl.pivot = UIWidget.Pivot.TopLeft; lbl.bitmapFont = bitmapFont; lbl.trueTypeFont = trueTypeFont; lbl.fontSize = fontSize; lbl.fontStyle = fontStyle; lbl.text = isLocalized ? Localization.Get(s) : s; lbl.color = textColor; lbl.cachedTransform.localPosition = new Vector3(bgPadding.x + padding.x - lbl.pivotOffset.x, y, -1f); lbl.overflowMethod = UILabel.Overflow.ResizeFreely; lbl.alignment = alignment; labels.Add(lbl); contentHeight += lineHeight; y -= lineHeight; x = Mathf.Max(x, lbl.printedSize.x); // Add an event listener UIEventListener listener = UIEventListener.Get(lbl.gameObject); listener.onHover = OnItemHover; listener.onPress = OnItemPress; listener.parameter = s; // Move the selection here if this is the right label if (mSelectedItem == s || (i == 0 && string.IsNullOrEmpty(mSelectedItem))) Highlight(lbl, true); // Add this label to the list mLabelList.Add(lbl); } // The triggering widget's width should be the minimum allowed width x = Mathf.Max(x, (max.x - min.x) - (bgPadding.x + padding.x) * 2f); float cx = x; Vector3 bcCenter = new Vector3(cx * 0.5f, -labelHeight * 0.5f, 0f); Vector3 bcSize = new Vector3(cx, (labelHeight + padding.y), 1f); // Run through all labels and add colliders for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; NGUITools.AddWidgetCollider(lbl.gameObject); lbl.autoResizeBoxCollider = false; BoxCollider bc = lbl.GetComponent<BoxCollider>(); if (bc != null) { bcCenter.z = bc.center.z; bc.center = bcCenter; bc.size = bcSize; } else { BoxCollider2D b2d = lbl.GetComponent<BoxCollider2D>(); #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 b2d.center = bcCenter; #else b2d.offset = bcCenter; #endif b2d.size = bcSize; } } int lblWidth = Mathf.RoundToInt(x); x += (bgPadding.x + padding.x) * 2f; y -= bgPadding.y; // Scale the background sprite to envelop the entire set of items mBackground.width = Mathf.RoundToInt(x); mBackground.height = Mathf.RoundToInt(contentHeight); // Set the label width to make alignment work for (int i = 0, imax = labels.Count; i < imax; ++i) { UILabel lbl = labels[i]; lbl.overflowMethod = UILabel.Overflow.ShrinkContent; lbl.width = lblWidth; } // Scale the highlight sprite to envelop a single item float scaleFactor = (atlas != null) ? 2f * atlas.pixelSize : 2f; float w = x - (bgPadding.x + padding.x) * 2f + hlspLeft * scaleFactor; float h = labelHeight + hlspHeight * scaleFactor; mHighlight.width = Mathf.RoundToInt(w); mHighlight.height = Mathf.RoundToInt(h); // If the list should be animated, let's animate it by expanding it if (isAnimated) { AnimateColor(mBackground); if (Time.timeScale == 0f || Time.timeScale >= 0.1f) { float bottom = y + labelHeight; Animate(mHighlight, placeAbove, bottom); for (int i = 0, imax = labels.Count; i < imax; ++i) Animate(labels[i], placeAbove, bottom); AnimateScale(mBackground, placeAbove, bottom); } } // If we need to place the popup list above the item, we need to reposition everything by the size of the list if (placeAbove) { min.y = max.y - bgPadding.y; max.y = min.y + mBackground.height; max.x = min.x + mBackground.width; t.localPosition = new Vector3(min.x, max.y - bgPadding.y, min.z); } else { max.y = min.y + bgPadding.y; min.y = max.y - mBackground.height; max.x = min.x + mBackground.width; } Transform pt = mPanel.cachedTransform.parent; if (pt != null) { min = mPanel.cachedTransform.TransformPoint(min); max = mPanel.cachedTransform.TransformPoint(max); min = pt.InverseTransformPoint(min); max = pt.InverseTransformPoint(max); } // Ensure that everything fits into the panel's visible range Vector3 offset = mPanel.hasClipping ? Vector3.zero : mPanel.CalculateConstrainOffset(min, max); Vector3 pos = t.localPosition + offset; pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); t.localPosition = pos; } else OnSelect(false); }
/// <summary> /// Manually close the popup list. /// </summary> public virtual void CloseSelf () { if (mChild != null && current == this) { StopCoroutine("CloseIfUnselected"); mSelection = null; mLabelList.Clear(); if (isAnimated) { UIWidget[] widgets = mChild.GetComponentsInChildren<UIWidget>(); for (int i = 0, imax = widgets.Length; i < imax; ++i) { UIWidget w = widgets[i]; Color c = w.color; c.a = 0f; TweenColor.Begin(w.gameObject, animSpeed, c).method = UITweener.Method.EaseOut; } Collider[] cols = mChild.GetComponentsInChildren<Collider>(); for (int i = 0, imax = cols.Length; i < imax; ++i) cols[i].enabled = false; Destroy(mChild, animSpeed); mFadeOutComplete = Time.unscaledTime + Mathf.Max(0.1f, animSpeed); } else { Destroy(mChild); mFadeOutComplete = Time.unscaledTime + 0.1f; } mBackground = null; mHighlight = null; mChild = null; current = null; } }
private static IEnumerator FadeInOut(UIBasicSprite sprite, float fadeInTime, float fadeOutTime) { sprite.enabled = true; sprite.alpha = 0; #region fade in while(sprite.alpha < 1) { sprite.alpha += Time.deltaTime / fadeInTime; yield return null; } sprite.alpha = 1; #endregion #region fade out while(sprite.alpha > 0) { sprite.alpha -= Time.deltaTime / fadeInTime; yield return null; } sprite.alpha = 0; sprite.enabled = false; #endregion }
void Cache () { mCached = true; mSprite = GetComponent<UISprite>(); }
public void SetFilled(UIBasicSprite.FillDirection fillDirection, bool invert) { if (sprite != null) { sprite.type = UIBasicSprite.Type.Filled; sprite.flip = UIBasicSprite.Flip.Nothing; sprite.fillDirection = fillDirection; sprite.fillAmount = 1; sprite.invert = invert; }else if (texture != null) { texture.type = UIBasicSprite.Type.Filled; texture.flip = UIBasicSprite.Flip.Nothing; texture.fillDirection = fillDirection; texture.fillAmount = 1; texture.invert = invert; } }
private static IEnumerator Blink(UIBasicSprite sprite, float time, float timeToStartBlink, int blinkRepetition) { yield return new WaitForSeconds(timeToStartBlink); float timeEachBlink = (time - timeToStartBlink) / (blinkRepetition * 2); for(byte i = 0; i < blinkRepetition; i++) { sprite.enabled = false; yield return new WaitForSeconds(timeEachBlink); sprite.enabled = true; yield return new WaitForSeconds(timeEachBlink); } sprite.enabled = false; }