void PrintSmily(string text) { if (mSmilyDrawObject == null) { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif mSmilyDrawObject = NGUITools.AddWidget <UITexture>(cachedGameObject); mSmilyDrawObject.name = "Smily Pass"; mSmilyDrawObject.material = mSmilyFont.material; mSmilyDrawObject.fillGeometry = false; mSmilyDrawObject.pivot = Pivot.TopLeft; mSmilyDrawObject.SetAnchor(cachedTransform); } else { mSmilyDrawObject.geometry.Clear(); mSmilyDrawObject.MarkAsChanged(); mSmilyDrawObject.SetDirty(); } UIGeometry geo = mSmilyDrawObject.geometry; NGUIText.Print(text, geo.verts, geo.uvs, geo.cols, true, true); }
protected override void OnInit() { if (null == geometry) { geometry = new UIGeometry(); } base.OnInit(); //OnFill(geometry.verts, geometry.uvs, geometry.cols); }
/// <summary> /// Fill the specified geometry buffer with vertices that would highlight the current selection. /// </summary> public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor) { if (caret != null) { caret.Clear(); } if (highlight != null) { highlight.Clear(); } if (!isValid) { return; } string text = processedText; UpdateNGUIText(); int startingCaretVerts = caret.verts.size; Vector2 center = new Vector2(0.5f, 0.5f); float alpha = finalAlpha; // If we have a highlight to work with, fill the buffer if (highlight != null && start != end) { int startingVertices = highlight.verts.size; NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, highlight.verts); if (highlight.verts.size > startingVertices) { ApplyOffset(highlight.verts, startingVertices); Color32 c = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * alpha); for (int i = startingVertices; i < highlight.verts.size; ++i) { highlight.uvs.Add(center); highlight.cols.Add(c); } } } else { NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, null); } // Fill the caret UVs and colors ApplyOffset(caret.verts, startingCaretVerts); Color32 cc = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * alpha); for (int i = startingCaretVerts; i < caret.verts.size; ++i) { caret.uvs.Add(center); caret.cols.Add(cc); } }
public void Rebuild() { if (null == geometry) { geometry = new UIGeometry(); } OnFill(geometry.verts, geometry.uvs, geometry.cols); gameObject.SetActive(false); gameObject.SetActive(true); }
private void OnDestroy() { Global.UnregisterWidget(this); if (this.mPanel != null) { this.mPanel.RemoveWidget(this); this.mPanel = null; } this.__mGeom = null; }
static public int Clear(IntPtr l) { try { UIGeometry self = (UIGeometry)checkSelf(l); self.Clear(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_verts(IntPtr l) { try { UIGeometry self = (UIGeometry)checkSelf(l); pushValue(l, true); pushValue(l, self.verts); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_hasTransformed(IntPtr l) { try { UIGeometry self = (UIGeometry)checkSelf(l); pushValue(l, true); pushValue(l, self.hasTransformed); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { UIGeometry o; o = new UIGeometry(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor) { if (caret != null) { caret.Clear(); } if (highlight != null) { highlight.Clear(); } if (!this.isValid) { return; } string processedText = this.processedText; this.UpdateNGUIText(); int size = caret.verts.size; Vector2 item = new Vector2(0.5f, 0.5f); float finalAlpha = this.finalAlpha; if (highlight != null && start != end) { int size2 = highlight.verts.size; NGUIText.PrintCaretAndSelection(processedText, start, end, caret.verts, highlight.verts); if (highlight.verts.size > size2) { this.ApplyOffset(highlight.verts, size2); Color32 item2 = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * finalAlpha); for (int i = size2; i < highlight.verts.size; i++) { highlight.uvs.Add(item); highlight.cols.Add(item2); } } } else { NGUIText.PrintCaretAndSelection(processedText, start, end, caret.verts, null); } this.ApplyOffset(caret.verts, size); Color32 item3 = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * finalAlpha); for (int j = size; j < caret.verts.size; j++) { caret.uvs.Add(item); caret.cols.Add(item3); } NGUIText.bitmapFont = null; NGUIText.dynamicFont = null; }
static public int ApplyTransform(IntPtr l) { try { UIGeometry self = (UIGeometry)checkSelf(l); UnityEngine.Matrix4x4 a1; checkValueType(l, 2, out a1); self.ApplyTransform(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int PrintOverlay(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 7); UILabel obj = (UILabel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UILabel"); int arg0 = (int)LuaScriptMgr.GetNumber(L, 2); int arg1 = (int)LuaScriptMgr.GetNumber(L, 3); UIGeometry arg2 = (UIGeometry)LuaScriptMgr.GetNetObject(L, 4, typeof(UIGeometry)); UIGeometry arg3 = (UIGeometry)LuaScriptMgr.GetNetObject(L, 5, typeof(UIGeometry)); Color arg4 = LuaScriptMgr.GetColor(L, 6); Color arg5 = LuaScriptMgr.GetColor(L, 7); obj.PrintOverlay(arg0, arg1, arg2, arg3, arg4, arg5); return(0); }
static public int set_verts(IntPtr l) { try { UIGeometry self = (UIGeometry)checkSelf(l); BetterList <UnityEngine.Vector3> v; checkType(l, 2, out v); self.verts = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int get_geometry(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIWidget obj = (UIWidget)o; UIGeometry ret = obj.geometry; ToLua.PushObject(L, ret); return 1; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e, o, "attempt to index geometry on a nil value"); } }
static int set_geometry(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIWidget obj = (UIWidget)o; UIGeometry arg0 = (UIGeometry)ToLua.CheckObject<UIGeometry>(L, 2); obj.geometry = arg0; return 0; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e, o, "attempt to index geometry on a nil value"); } }
public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor) { caret?.Clear(); highlight?.Clear(); if (!isValid) { return; } string text = processedText; UpdateNGUIText(); int size = caret.verts.size; Vector2 item = new Vector2(0.5f, 0.5f); float num = finalAlpha; if (highlight != null && start != end) { int size2 = highlight.verts.size; NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, highlight.verts); if (highlight.verts.size > size2) { ApplyOffset(highlight.verts, size2); Color32 item2 = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * num); for (int i = size2; i < highlight.verts.size; i++) { highlight.uvs.Add(item); highlight.cols.Add(item2); } } } else { NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, null); } ApplyOffset(caret.verts, size); Color32 item3 = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * num); for (int i = size; i < caret.verts.size; i++) { caret.uvs.Add(item); caret.cols.Add(item3); } }
static int PrintOverlay(IntPtr L) { try { ToLua.CheckArgsCount(L, 7); UILabel obj = (UILabel)ToLua.CheckObject<UILabel>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); UIGeometry arg2 = (UIGeometry)ToLua.CheckObject<UIGeometry>(L, 4); UIGeometry arg3 = (UIGeometry)ToLua.CheckObject<UIGeometry>(L, 5); UnityEngine.Color arg4 = ToLua.ToColor(L, 6); UnityEngine.Color arg5 = ToLua.ToColor(L, 7); obj.PrintOverlay(arg0, arg1, arg2, arg3, arg4, arg5); return 0; } catch (Exception e) { return LuaDLL.toluaL_exception(L, e); } }
static public int WriteToBuffers(IntPtr l) { try { UIGeometry self = (UIGeometry)checkSelf(l); BetterList <UnityEngine.Vector3> a1; checkType(l, 2, out a1); BetterList <UnityEngine.Vector2> a2; checkType(l, 3, out a2); BetterList <UnityEngine.Color32> a3; checkType(l, 4, out a3); BetterList <UnityEngine.Vector3> a4; checkType(l, 5, out a4); BetterList <UnityEngine.Vector4> a5; checkType(l, 6, out a5); self.WriteToBuffers(a1, a2, a3, a4, a5); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
/// <summary> /// Fill the specified geometry buffer with vertices that would highlight the current selection. /// </summary> public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor) { if (caret != null) caret.Clear(); if (highlight != null) highlight.Clear(); if (!isValid) return; string text = processedText; UpdateNGUIText(); int startingCaretVerts = caret.verts.size; Vector2 center = new Vector2(0.5f, 0.5f); float alpha = finalAlpha; // If we have a highlight to work with, fill the buffer if (highlight != null && start != end) { int startingVertices = highlight.verts.size; NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, highlight.verts); if (highlight.verts.size > startingVertices) { ApplyOffset(highlight.verts, startingVertices); Color32 c = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * alpha); for (int i = startingVertices; i < highlight.verts.size; ++i) { highlight.uvs.Add(center); highlight.cols.Add(c); } } } else NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, null); // Fill the caret UVs and colors ApplyOffset(caret.verts, startingCaretVerts); Color32 cc = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * alpha); for (int i = startingCaretVerts; i < caret.verts.size; ++i) { caret.uvs.Add(center); caret.cols.Add(cc); } NGUIText.bitmapFont = null; NGUIText.dynamicFont = null; }
/// <summary> /// Fill the specified geometry buffer with vertices that would highlight the current selection. /// </summary> public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor) { if (caret != null) { caret.Clear(); } if (highlight != null) { highlight.Clear(); } if (!isValid) { return; } string text = processedText; float pixelSize = (mFont != null) ? mFont.pixelSize : 1f; float scale = mScale * pixelSize; bool usePS = usePrintedSize; if (usePS) { UpdateNGUIText(mPrintedSize, mWidth, mHeight); } else { UpdateNGUIText(fontSize, Mathf.RoundToInt(mWidth / scale), mHeight); } int startingCaretVerts = caret.verts.size; Vector2 center = new Vector2(0.5f, 0.5f); float alpha = finalAlpha; // If we have a highlight to work with, fill the buffer if (highlight != null && start != end) { int startingVertices = highlight.verts.size; NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, highlight.verts); if (highlight.verts.size > startingVertices) { ApplyOffset(highlight.verts, usePS, scale, startingVertices); Color32 c = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * alpha); for (int i = startingVertices; i < highlight.verts.size; ++i) { highlight.uvs.Add(center); highlight.cols.Add(c); } } } else { NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, null); } // Fill the caret UVs and colors ApplyOffset(caret.verts, usePS, scale, startingCaretVerts); Color32 cc = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * alpha); for (int i = startingCaretVerts; i < caret.verts.size; ++i) { caret.uvs.Add(center); caret.cols.Add(cc); } }
public bool UpdateGeometry(ref Matrix4x4 worldToPanel, bool parentMoved, bool generateNormals) { Vector3 vector3 = new Vector3(); Vector2 vector2; Vector2 vector21 = new Vector2(); float single; if (!this.material) { return(false); } UIGeometry uIGeometry = this.mGeom; if (!this.OnUpdate() && !this.mChangedCall && !this.mForcedChanged) { if (uIGeometry.hasVertices && parentMoved) { Matrix4x4 matrix4x4 = worldToPanel * this.cachedTransform.localToWorldMatrix; uIGeometry.Apply(ref matrix4x4); } return(false); } this.mChangedCall = false; this.mForcedChanged = false; uIGeometry.Clear(); if (this.mAlphaUnchecked || !NGUITools.ZeroAlpha(this.mColor.a)) { this.OnFill(uIGeometry.meshBuffer); } if (uIGeometry.hasVertices) { switch ((byte)(this.widgetFlags & (UIWidget.WidgetFlags.CustomPivotOffset | UIWidget.WidgetFlags.CustomRelativeSize))) { case 1: { UIWidget.tempWidgetFlags[0] = UIWidget.WidgetFlags.CustomPivotOffset; this.GetCustomVector2s(0, 1, UIWidget.tempWidgetFlags, UIWidget.tempVector2s); vector2 = UIWidget.tempVector2s[0]; float single1 = 1f; single = single1; vector21.y = single1; vector21.x = single; break; } case 2: { UIWidget.tempWidgetFlags[0] = UIWidget.WidgetFlags.CustomRelativeSize; this.GetCustomVector2s(0, 1, UIWidget.tempWidgetFlags, UIWidget.tempVector2s); vector21 = UIWidget.tempVector2s[0]; vector2 = UIWidget.DefaultPivot(this.mPivot); break; } case 3: { UIWidget.tempWidgetFlags[0] = UIWidget.WidgetFlags.CustomPivotOffset; UIWidget.tempWidgetFlags[1] = UIWidget.WidgetFlags.CustomRelativeSize; this.GetCustomVector2s(0, 2, UIWidget.tempWidgetFlags, UIWidget.tempVector2s); vector2 = UIWidget.tempVector2s[0]; vector21 = UIWidget.tempVector2s[1]; break; } default: { vector2 = UIWidget.DefaultPivot(this.mPivot); float single2 = 1f; single = single2; vector21.y = single2; vector21.x = single; break; } } vector3.x = vector2.x * vector21.x; vector3.y = vector2.y * vector21.y; vector3.z = 0f; Matrix4x4 matrix4x41 = worldToPanel * this.cachedTransform.localToWorldMatrix; uIGeometry.Apply(ref vector3, ref matrix4x41); } return(true); }
/// <summary> /// Sliced sprite fill function is more complicated as it generates 9 quads instead of 1. /// </summary> void SlicedFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, UIGeometry uig) { Vector4 br = border * pixelSize; if (br.x == 0f && br.y == 0f && br.z == 0f && br.w == 0f) { SimpleFill(verts, uvs, cols, uig); return; } #if (OPTIMISE_GC_SY_20190426) if (uig != null) { if (uig.m_pUIWidget != null) { if (uig.m_pUIWidget.bLocalVertexBuffer) { RealSlicedFill(verts, uvs, cols); } else { uig.m_vertexnum = centerType == AdvancedType.Invisible ? 32 : 36; } } return; } #else RealSlicedFill(verts, uvs, cols); #endif }
/// <summary> /// Fill the specified geometry buffer with vertices that would highlight the current selection. /// </summary> public void PrintOverlay (int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor) { if (caret != null) caret.Clear(); if (highlight != null) highlight.Clear(); if (!isValid) return; string text = processedText; float pixelSize = (mFont != null) ? mFont.pixelSize : 1f; float scale = mScale * pixelSize; bool usePS = usePrintedSize; if (usePS) UpdateNGUIText(mPrintedSize, mWidth, mHeight); else UpdateNGUIText(fontSize, Mathf.RoundToInt(mWidth / scale), mHeight); int startingCaretVerts = caret.verts.size; Vector2 center = new Vector2(0.5f, 0.5f); float alpha = finalAlpha; // If we have a highlight to work with, fill the buffer if (highlight != null && start != end) { int startingVertices = highlight.verts.size; NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, highlight.verts); if (highlight.verts.size > startingVertices) { ApplyOffset(highlight.verts, usePS, scale, startingVertices); Color32 c = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * alpha); for (int i = startingVertices; i < highlight.verts.size; ++i) { highlight.uvs.Add(center); highlight.cols.Add(c); } } } else NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, null); // Fill the caret UVs and colors ApplyOffset(caret.verts, usePS, scale, startingCaretVerts); Color32 cc = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * alpha); for (int i = startingCaretVerts; i < caret.verts.size; ++i) { caret.uvs.Add(center); caret.cols.Add(cc); } }
void SimpleFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, UIGeometry uig = null) { #if (OPTIMISE_GC_SY_20190426) if (uig != null) { if (uig.m_pUIWidget != null) { if (uig.m_pUIWidget.bLocalVertexBuffer) { RealSimpleFill(verts, uvs, cols); } else { uig.m_vertexnum = 4; } } return; } #else RealSimpleFill(verts, uvs, cols); #endif }
public bool UpdateGeometry(ref Matrix4x4 worldToPanel, bool parentMoved, bool generateNormals) { if (this.material == null) { return(false); } UIGeometry mGeom = this.mGeom; if ((!this.OnUpdate() && !this.mChangedCall) && !this.mForcedChanged) { if (mGeom.hasVertices && parentMoved) { Matrix4x4 widgetToPanel = worldToPanel * this.cachedTransform.localToWorldMatrix; mGeom.Apply(ref widgetToPanel); } return(false); } this.mChangedCall = false; this.mForcedChanged = false; mGeom.Clear(); if (this.mAlphaUnchecked || !NGUITools.ZeroAlpha(this.mColor.a)) { this.OnFill(mGeom.meshBuffer); } if (mGeom.hasVertices) { Vector3 vector; Vector2 vector2; Vector2 vector3; switch (((WidgetFlags)((byte)(this.widgetFlags & (WidgetFlags.CustomPivotOffset | WidgetFlags.CustomRelativeSize))))) { case WidgetFlags.CustomPivotOffset: tempWidgetFlags[0] = WidgetFlags.CustomPivotOffset; this.GetCustomVector2s(0, 1, tempWidgetFlags, tempVector2s); vector2 = tempVector2s[0]; vector3.x = vector3.y = 1f; break; case WidgetFlags.CustomRelativeSize: tempWidgetFlags[0] = WidgetFlags.CustomRelativeSize; this.GetCustomVector2s(0, 1, tempWidgetFlags, tempVector2s); vector3 = tempVector2s[0]; vector2 = DefaultPivot(this.mPivot); break; case (WidgetFlags.CustomPivotOffset | WidgetFlags.CustomRelativeSize): tempWidgetFlags[0] = WidgetFlags.CustomPivotOffset; tempWidgetFlags[1] = WidgetFlags.CustomRelativeSize; this.GetCustomVector2s(0, 2, tempWidgetFlags, tempVector2s); vector2 = tempVector2s[0]; vector3 = tempVector2s[1]; break; default: vector2 = DefaultPivot(this.mPivot); vector3.x = vector3.y = 1f; break; } vector.x = vector2.x * vector3.x; vector.y = vector2.y * vector3.y; vector.z = 0f; Matrix4x4 matrixx = worldToPanel * this.cachedTransform.localToWorldMatrix; mGeom.Apply(ref vector, ref matrixx); } return(true); }
/// <summary> /// Advanced sprite fill function. Contributed by Nicki Hansen. /// </summary> void AdvancedFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, UIGeometry uig) { Texture tex = mainTexture; if (tex == null) { return; } Vector4 br = border * pixelSize; if (br.x == 0f && br.y == 0f && br.z == 0f && br.w == 0f) { SimpleFill(verts, uvs, cols, uig); return; } Color32 c = drawingColor; Vector4 v = drawingDimensions; Vector2 tileSize = new Vector2(mInnerUV.width * tex.width, mInnerUV.height * tex.height); tileSize *= pixelSize; if (tileSize.x < 1f) { tileSize.x = 1f; } if (tileSize.y < 1f) { tileSize.y = 1f; } mTempPos[0].x = v.x; mTempPos[0].y = v.y; mTempPos[3].x = v.z; mTempPos[3].y = v.w; if (mFlip == Flip.Horizontally || mFlip == Flip.Both) { mTempPos[1].x = mTempPos[0].x + br.z; mTempPos[2].x = mTempPos[3].x - br.x; mTempUVs[3].x = mOuterUV.xMin; mTempUVs[2].x = mInnerUV.xMin; mTempUVs[1].x = mInnerUV.xMax; mTempUVs[0].x = mOuterUV.xMax; } else { mTempPos[1].x = mTempPos[0].x + br.x; mTempPos[2].x = mTempPos[3].x - br.z; mTempUVs[0].x = mOuterUV.xMin; mTempUVs[1].x = mInnerUV.xMin; mTempUVs[2].x = mInnerUV.xMax; mTempUVs[3].x = mOuterUV.xMax; } if (mFlip == Flip.Vertically || mFlip == Flip.Both) { mTempPos[1].y = mTempPos[0].y + br.w; mTempPos[2].y = mTempPos[3].y - br.y; mTempUVs[3].y = mOuterUV.yMin; mTempUVs[2].y = mInnerUV.yMin; mTempUVs[1].y = mInnerUV.yMax; mTempUVs[0].y = mOuterUV.yMax; } else { mTempPos[1].y = mTempPos[0].y + br.y; mTempPos[2].y = mTempPos[3].y - br.w; mTempUVs[0].y = mOuterUV.yMin; mTempUVs[1].y = mInnerUV.yMin; mTempUVs[2].y = mInnerUV.yMax; mTempUVs[3].y = mOuterUV.yMax; } for (int x = 0; x < 3; ++x) { int x2 = x + 1; for (int y = 0; y < 3; ++y) { if (centerType == AdvancedType.Invisible && x == 1 && y == 1) { continue; } int y2 = y + 1; if (x == 1 && y == 1) // Center { if (centerType == AdvancedType.Tiled) { float startPositionX = mTempPos[x].x; float endPositionX = mTempPos[x2].x; float startPositionY = mTempPos[y].y; float endPositionY = mTempPos[y2].y; float textureStartX = mTempUVs[x].x; float textureStartY = mTempUVs[y].y; float tileStartY = startPositionY; while (tileStartY < endPositionY) { float tileStartX = startPositionX; float textureEndY = mTempUVs[y2].y; float tileEndY = tileStartY + tileSize.y; if (tileEndY > endPositionY) { textureEndY = Mathf.Lerp(textureStartY, textureEndY, (endPositionY - tileStartY) / tileSize.y); tileEndY = endPositionY; } while (tileStartX < endPositionX) { float tileEndX = tileStartX + tileSize.x; float textureEndX = mTempUVs[x2].x; if (tileEndX > endPositionX) { textureEndX = Mathf.Lerp(textureStartX, textureEndX, (endPositionX - tileStartX) / tileSize.x); tileEndX = endPositionX; } Fill(verts, uvs, cols, tileStartX, tileEndX, tileStartY, tileEndY, textureStartX, textureEndX, textureStartY, textureEndY, c); tileStartX += tileSize.x; } tileStartY += tileSize.y; } } else if (centerType == AdvancedType.Sliced) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } else if (x == 1) // Top or bottom { if ((y == 0 && bottomType == AdvancedType.Tiled) || (y == 2 && topType == AdvancedType.Tiled)) { float startPositionX = mTempPos[x].x; float endPositionX = mTempPos[x2].x; float startPositionY = mTempPos[y].y; float endPositionY = mTempPos[y2].y; float textureStartX = mTempUVs[x].x; float textureStartY = mTempUVs[y].y; float textureEndY = mTempUVs[y2].y; float tileStartX = startPositionX; while (tileStartX < endPositionX) { float tileEndX = tileStartX + tileSize.x; float textureEndX = mTempUVs[x2].x; if (tileEndX > endPositionX) { textureEndX = Mathf.Lerp(textureStartX, textureEndX, (endPositionX - tileStartX) / tileSize.x); tileEndX = endPositionX; } Fill(verts, uvs, cols, tileStartX, tileEndX, startPositionY, endPositionY, textureStartX, textureEndX, textureStartY, textureEndY, c); tileStartX += tileSize.x; } } else if ((y == 0 && bottomType != AdvancedType.Invisible) || (y == 2 && topType != AdvancedType.Invisible)) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } else if (y == 1) // Left or right { if ((x == 0 && leftType == AdvancedType.Tiled) || (x == 2 && rightType == AdvancedType.Tiled)) { float startPositionX = mTempPos[x].x; float endPositionX = mTempPos[x2].x; float startPositionY = mTempPos[y].y; float endPositionY = mTempPos[y2].y; float textureStartX = mTempUVs[x].x; float textureEndX = mTempUVs[x2].x; float textureStartY = mTempUVs[y].y; float tileStartY = startPositionY; while (tileStartY < endPositionY) { float textureEndY = mTempUVs[y2].y; float tileEndY = tileStartY + tileSize.y; if (tileEndY > endPositionY) { textureEndY = Mathf.Lerp(textureStartY, textureEndY, (endPositionY - tileStartY) / tileSize.y); tileEndY = endPositionY; } Fill(verts, uvs, cols, startPositionX, endPositionX, tileStartY, tileEndY, textureStartX, textureEndX, textureStartY, textureEndY, c); tileStartY += tileSize.y; } } else if ((x == 0 && leftType != AdvancedType.Invisible) || (x == 2 && rightType != AdvancedType.Invisible)) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } else // Corner { if ((y == 0 && bottomType != AdvancedType.Invisible) || (y == 2 && topType != AdvancedType.Invisible) || (x == 0 && leftType != AdvancedType.Invisible) || (x == 2 && rightType != AdvancedType.Invisible)) { Fill(verts, uvs, cols, mTempPos[x].x, mTempPos[x2].x, mTempPos[y].y, mTempPos[y2].y, mTempUVs[x].x, mTempUVs[x2].x, mTempUVs[y].y, mTempUVs[y2].y, c); } } } } }
public static void PullFromCachedGeometries(int vertexCount, UIGeometry geometry) { PullFromCachedGeometries(vertexCount, ref geometry.verts, ref geometry.uvs, ref geometry.cols, ref geometry.mRtpVerts); }
/// <summary> /// Fill the draw buffers. /// </summary> protected void Fill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, Rect outer, Rect inner, UIGeometry uig) { //Profiler.BeginSample("UIBasicSprite:Fill"); mOuterUV = outer; mInnerUV = inner; switch (type) { case Type.Simple: //Profiler.BeginSample("SimpleFill"); SimpleFill(verts, uvs, cols, uig); //Profiler.EndSample(); break; case Type.Sliced: //Profiler.BeginSample("SlicedFill"); SlicedFill(verts, uvs, cols, uig); //Profiler.EndSample(); break; case Type.Filled: //Profiler.BeginSample("FilledFill"); FilledFill(verts, uvs, cols, uig); //Profiler.EndSample(); break; case Type.Tiled: //Profiler.BeginSample("TiledFill"); TiledFill(verts, uvs, cols); //Profiler.EndSample(); break; case Type.Advanced: //Profiler.BeginSample("AdvancedFill"); AdvancedFill(verts, uvs, cols, uig); //Profiler.EndSample(); break; } //Profiler.EndSample(); }
private void OnDestroy() { UIWidget.Global.UnregisterWidget(this); if (this.mPanel != null) { this.mPanel.RemoveWidget(this); this.mPanel = null; } this.__mGeom = null; }
public static void PushToCachedGeometries(UIGeometry geometry) { PushToCachedGeometries(geometry.verts, geometry.uvs, geometry.cols, geometry.mRtpVerts); }
/// <summary> /// Filled sprite fill function. /// </summary> void FilledFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, UIGeometry uig) { //RealFilledFill(verts, uvs, cols); //return; #if (OPTIMISE_GC_SY_20190426) if (uig != null) { if (uig.m_pUIWidget != null) { if (uig.m_pUIWidget.bLocalVertexBuffer) { RealFilledFill(verts, uvs, cols); } else { UIBasicSprite ubs = uig.m_pUIWidget as UIBasicSprite; if (ubs.mFillAmount < 0.001f) { uig.m_vertexnum = 0; } else { uig.m_vertexnum = 4; } } } return; } #else RealFilledFill(verts, uvs, cols); #endif }
/// <summary> /// Virtual function called by the UIPanel that fills the buffers. /// </summary> public override void OnFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, UIGeometry uig = null) { //Profiler.BeginSample("UITexture:OnFill"); Texture tex = mainTexture; if (tex == null) { return; } Rect outer = new Rect(mRect.x * tex.width, mRect.y * tex.height, tex.width * mRect.width, tex.height * mRect.height); Rect inner = outer; Vector4 br = border; inner.xMin += br.x; inner.yMin += br.y; inner.xMax -= br.z; inner.yMax -= br.w; float w = 1f / tex.width; float h = 1f / tex.height; outer.xMin *= w; outer.xMax *= w; outer.yMin *= h; outer.yMax *= h; inner.xMin *= w; inner.xMax *= w; inner.yMin *= h; inner.yMax *= h; int offset = verts.size; Fill(verts, uvs, cols, outer, inner, uig); if (onPostFill != null) { onPostFill(this, offset, verts, uvs, cols); } //Profiler.EndSample(); }
/// <summary> /// Virtual function called by the UIPanel that fills the buffers. /// </summary> public override void OnFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, UIGeometry uig = null) { //Profiler.BeginSample("UISprite:OnFill"); Texture tex = mainTexture; if (tex == null) { return; } if (mSprite == null) { mSprite = atlas.GetSprite(spriteName); } if (mSprite == null) { return; } Rect outer = new Rect(mSprite.x, mSprite.y, mSprite.width, mSprite.height); Rect inner = new Rect(mSprite.x + mSprite.borderLeft, mSprite.y + mSprite.borderTop, mSprite.width - mSprite.borderLeft - mSprite.borderRight, mSprite.height - mSprite.borderBottom - mSprite.borderTop); outer = NGUIMath.ConvertToTexCoords(outer, tex.width, tex.height); inner = NGUIMath.ConvertToTexCoords(inner, tex.width, tex.height); int offset = verts.size; Fill(verts, uvs, cols, outer, inner, uig); if (onPostFill != null) { onPostFill(this, offset, verts, uvs, cols); } //Profiler.EndSample(); }