public void updateUnderline() { if (Underline && lineGameObject != null) { if (underlineEnd != text.Length) { underlineEnd = text.Length; } lineImage.color = canvasRenderer.GetColor(); if (textGenerator.characterCount < 0) { return; } UICharInfo[] charactersInfo = textGenerator.GetCharactersArray(); if (!(underlineEnd > underlineStart && underlineEnd < charactersInfo.Length)) { return; } UILineInfo[] linesInfo = textGenerator.GetLinesArray(); if (linesInfo.Length < 1) { return; } float height = linesInfo[0].height; Canvas canvas = gameObject.GetComponentInParent <Canvas>(); float factor = 1.0f / canvas.scaleFactor; lineRectTransform.anchoredPosition = new Vector2( factor * (charactersInfo[underlineStart].cursorPos.x + charactersInfo[underlineEnd].cursorPos.x) / 2.0f, factor * (charactersInfo[underlineStart].cursorPos.y - height / 1.0f) ); lineRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, factor * Mathf.Abs(charactersInfo[underlineStart].cursorPos.x - charactersInfo[underlineEnd].cursorPos.x)); lineRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height / 10.0f); } }
static public IEnumerator ColorTo(this CanvasRenderer inRenderer, Color inColor, float inTime, bool inbPreserveAlpha = true, AnimationCurve inCurve = null) { Color currentColor = inRenderer.GetColor(); float currentPercentage = 0.0f; float percentageIncrement = 1.0f / inTime; while (currentPercentage < 1) { yield return(null); currentPercentage += Time.deltaTime * percentageIncrement; if (currentPercentage > 1) { currentPercentage = 1; } float curvedPercentage = currentPercentage; if (inCurve != null) { curvedPercentage = inCurve.Evaluate(curvedPercentage); } Color nextColor = Color.LerpUnclamped(currentColor, inColor, curvedPercentage); if (inbPreserveAlpha) { nextColor.a = currentColor.a; } inRenderer.SetColor(nextColor); } }
public override void OnCursorInit(Cursor cursor) { base.OnCursorInit(cursor); oldColor = canvasRenderer.GetColor(); pageSelectCursor = cursor; canvasRenderer.SetColor(overlayColor); }
public void OnEnable() { if (oldColor == new Color()) { oldColor = canvasRenderer.GetColor(); } canvasRenderer.SetColor(overlayColor); }
void Update() { if (clicktostop) { if ((Input.GetMouseButton(0) || Input.touchCount > 0) && istouched) { istouched = true; } } if (!istouched) { if (!isblinkenable) { return; } else { float alpha = ren.GetColor().a; if (alpha <= 0) { isincreasing = true; } else if (alpha >= 1) { isincreasing = false; } if (isincreasing) { alpha += blinkspeed; } else { alpha -= blinkspeed; } ren.SetColor(new Color(ren.GetColor().r, ren.GetColor().g, ren.GetColor().b, alpha)); } } }
private void addUnderline() { textRectTransform = gameObject.GetComponent <RectTransform>(); textGenerator = cachedTextGenerator; lineGameObject = new GameObject("Underline"); lineImage = lineGameObject.AddComponent <Image>(); canvasRenderer = GetComponent <CanvasRenderer>(); lineImage.color = canvasRenderer.GetColor(); lineRectTransform = lineGameObject.GetComponent <RectTransform>(); lineRectTransform.SetParent(transform, false); lineRectTransform.anchorMin = textRectTransform.pivot; lineRectTransform.anchorMax = textRectTransform.pivot; }
private void IconColorGreenToWhite() { if (imageCanvas.GetColor() != white) { Color iconColor = imageCanvas.GetColor(); iconColor = iconColor + new Color(0.01f, 0, 0.01f); SetIconColor(iconColor); if (imageCanvas.transform.localScale.x > .7f && animateHealth) { imageCanvas.transform.localScale -= new Vector3(0.05f, 0.05f, 0.05f); } else { imageCanvas.transform.localScale = new Vector3(1, 1, 1); animateHealth = false; } } else { colorChangedToGreen = false; } }
void Start() { m_Renderer = GetComponent <CanvasRenderer>(); if (m_Renderer) { m_StartColor = m_Renderer.GetColor(); } m_ItemImage = transform.FindChild("ItemImage").GetComponent <Image>(); if (m_ItemImage) { m_ItemImage.enabled = false; } }
IEnumerator FadeOut(GameObject obj, float delay) { obj.SetActive(true); yield return(new WaitForSeconds(delay)); CanvasRenderer renderer = obj.GetComponent <CanvasRenderer>(); for (int i = 0; i < 100; i++) { Color color = renderer.GetColor(); color.a = 1 - (i * 0.01F); renderer.SetColor(color); yield return(new WaitForSeconds(0.01F)); } obj.SetActive(false); }
IEnumerator FadeIn(GameObject obj, Action action) { obj.SetActive(true); CanvasRenderer renderer = obj.GetComponent <CanvasRenderer>(); for (int i = 0; i < 100; i++) { Color color = renderer.GetColor(); color.a = i * 0.01F; renderer.SetColor(color); yield return(new WaitForSeconds(0.001F)); } if (action != null) { action(); } }
void Start() { m_Stats = GameObject.FindGameObjectWithTag("Player").GetComponent <EntityStats>(); m_Player = m_Stats.gameObject.GetComponent <PlayerController>(); m_Renderer = GetComponent <CanvasRenderer>(); m_ItemImage = transform.FindChild("ItemImage").GetComponentInChildren <Image>(); if (m_Renderer) { m_StartColor = m_Renderer.GetColor(); } if (m_ItemImage) { m_ItemImage.enabled = false; } }
public static int GetColor(IntPtr l) { int result; try { CanvasRenderer canvasRenderer = (CanvasRenderer)LuaObject.checkSelf(l); Color color = canvasRenderer.GetColor(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, color); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
private void getUnderlineObject() { foreach (Transform child in transform) { if (child.name == "Underline") { textRectTransform = gameObject.GetComponent <RectTransform>(); textGenerator = cachedTextGenerator; lineGameObject = child.gameObject; lineImage = lineGameObject.GetComponent <Image>(); canvasRenderer = GetComponent <CanvasRenderer>(); lineImage.color = canvasRenderer.GetColor(); lineRectTransform = lineGameObject.GetComponent <RectTransform>(); lineRectTransform.SetParent(transform, false); lineRectTransform.anchorMin = textRectTransform.pivot; lineRectTransform.anchorMax = textRectTransform.pivot; } } }
//============================================================================== // 関数 //============================================================================== /// <summary> /// 初期化します /// </summary> private void Init() { if (m_isInit) { return; } m_isInit = true; m_canvasRenderer = GetComponent <CanvasRenderer>(); m_defaultColor = m_canvasRenderer.GetColor(); m_grayOutColor = new Color ( m_defaultColor.r * GrayOutColor.r, m_defaultColor.g * GrayOutColor.g, m_defaultColor.b * GrayOutColor.b, m_defaultColor.a * GrayOutColor.a ); }
//Buttonを半透明にしないで現在の状態のままinteractable = false;に変更します private IEnumerator Locking() { //Buttonの色がFadeを完了されるまで待ちます //fadeDurationの値によってFadeにかかる時間は変わりますデフォルトでは0.1fです yield return(new WaitForSeconds(0.2f)); foreach (var item in sideButtons) { //Buttonの現在の色を取得します //Buttonを押したときに変化するselectedColorはCanvasRendererによって色を重ねているためです CanvasRenderer canvasRenderer = item.gameObject.GetComponent <CanvasRenderer>(); Color color = canvasRenderer.GetColor(); ColorBlock colorBlock = item.colors; colorBlock.disabledColor = color; item.colors = colorBlock; item.interactable = false; } yield break; }
/// <inheritdoc /> protected override Color GetColour() { return(UIElement.GetColor()); }
public void OnTweenStart() { m_Start = m_Renderer.GetColor(); }
public CanvasRendererProperties(CanvasRenderer canvasRenderer) { alpha = canvasRenderer.GetAlpha(); color = canvasRenderer.GetColor(); }
protected virtual void OnPopulateMesh(VertexHelper vh) { vh.Clear(); if ((double)Mathf.Abs(this.MinAngle - this.MaxAngle) <= 1.0 || (double)this.Step <= 1.40129846432482E-45) { return; } UIVertex uiVertex = (UIVertex)null; CanvasRenderer canvasRenderer = ((Graphic)this).get_canvasRenderer(); Sprite sprite = this.get_sprite(); Vector2 zero1 = Vector2.get_zero(); Vector2 zero2 = Vector2.get_zero(); float num1; if (Object.op_Inequality((Object)sprite, (Object)null)) { float num2 = 1f / (float)((Texture)sprite.get_texture()).get_width(); float num3 = 1f / (float)((Texture)sprite.get_texture()).get_height(); Rect rect = sprite.get_rect(); // ISSUE: explicit reference operation zero1.x = (__Null)(((Rect)@rect).get_min().x *(double)num2); // ISSUE: explicit reference operation zero1.y = (__Null)(((Rect)@rect).get_min().y *(double)num3); // ISSUE: explicit reference operation zero2.x = (__Null)(((Rect)@rect).get_max().x *(double)num2); // ISSUE: explicit reference operation zero2.y = (__Null)(((Rect)@rect).get_max().y *(double)num3); // ISSUE: explicit reference operation num1 = ((Rect)@rect).get_width(); } else { num1 = float.MaxValue; } float step = this.Step; float num4; float num5; if ((double)this.MinAngle < (double)this.MaxAngle) { num4 = this.MinAngle; num5 = this.MaxAngle; } else { num4 = this.MaxAngle; num5 = this.MinAngle; } int num6 = 0; float num7 = num4 * ((float)Math.PI / 180f); uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num7) * this.RadiusMax, Mathf.Sin(num7) * this.RadiusMax)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).x = zero1.x; // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero2.y; vh.AddVert(uiVertex); uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num7) * this.RadiusMin, Mathf.Sin(num7) * this.RadiusMin)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).x = zero1.x; // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero1.y; vh.AddVert(uiVertex); float num8 = 0.0f; float num9 = num4; float num10 = (float)(Math.PI / 180.0 * (double)this.RadiusMin * 2.0) * this.Tiling; while (true) { float num2 = num9 + step; float num3 = (num9 - num4) * num10; float num11 = (num2 - num4) * num10; num8 += num11 - num3; bool flag = false; if ((double)num8 >= (double)num1) { float num12 = (float)((double)num8 / (double)num1 - 1.0); num2 = num9 + step * num12; num8 = 0.0f; flag = true; } num9 = num2; if ((double)num9 < (double)num5) { float num12 = num9 * ((float)Math.PI / 180f); float num13 = num8 / num1; uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num12) * this.RadiusMin, Mathf.Sin(num12) * this.RadiusMin)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); if (flag) { // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).x = zero2.x; } else { // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).x = (__Null)((zero2.x - zero1.x) * (double)num13 + zero1.x); } // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero1.y; vh.AddVert(uiVertex); uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num12) * this.RadiusMax, Mathf.Sin(num12) * this.RadiusMax)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero2.y; vh.AddVert(uiVertex); vh.AddTriangle(num6, num6 + 1, num6 + 2); vh.AddTriangle(num6 + 2, num6 + 3, num6); num6 += 4; if (flag) { // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).x = zero1.x; } uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num12) * this.RadiusMax, Mathf.Sin(num12) * this.RadiusMax)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero2.y; vh.AddVert(uiVertex); uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num12) * this.RadiusMin, Mathf.Sin(num12) * this.RadiusMin)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero1.y; vh.AddVert(uiVertex); } else { break; } } float num14 = num5 * ((float)Math.PI / 180f); float num15 = (num8 + (num5 - num9) * num10) / num1; // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).x = (__Null)((zero2.x - zero1.x) * (double)num15 + zero1.x); uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num14) * this.RadiusMin, Mathf.Sin(num14) * this.RadiusMin)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero1.y; vh.AddVert(uiVertex); uiVertex.position = (__Null)Vector2.op_Implicit(new Vector2(Mathf.Cos(num14) * this.RadiusMax, Mathf.Sin(num14) * this.RadiusMax)); uiVertex.color = (__Null)Color32.op_Implicit(canvasRenderer.GetColor()); // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation (^ (Vector2&)@uiVertex.uv0).y = zero2.y; vh.AddVert(uiVertex); vh.AddTriangle(num6, num6 + 1, num6 + 2); vh.AddTriangle(num6 + 2, num6 + 3, num6); int num16 = num6 + 4; }
void Update() { text.color = ren.GetColor().Invert(); }