Esempio n. 1
0
	private static UIDrawCall Create(string name, UIPanel pan, Material mat, Texture tex, Shader shader)
	{
		UIDrawCall uIDrawCall = UIDrawCall.Create(name);
		uIDrawCall.gameObject.layer = pan.cachedGameObject.layer;
		uIDrawCall.baseMaterial = mat;
		uIDrawCall.mainTexture = tex;
		uIDrawCall.shader = shader;
		uIDrawCall.renderQueue = pan.startingRenderQueue;
		uIDrawCall.sortingOrder = pan.sortingOrder;
		uIDrawCall.manager = pan;
		return uIDrawCall;
	}
Esempio n. 2
0
    public static UIDrawCall CreateMerge(UIPanel pan, Material mat, Shader shader)
    {
        UIDrawCall uIDrawCall = UIDrawCall.Create(pan.name);

        uIDrawCall.gameObject.layer = pan.cachedGameObject.layer;
        uIDrawCall.baseMaterial     = mat;
        uIDrawCall.mainTexture      = null;
        uIDrawCall.alphaTexture     = null;
        uIDrawCall.shader           = shader;
        uIDrawCall.renderQueue      = pan.startingRenderQueue;
        uIDrawCall.sortingOrder     = pan.sortingOrder;
        uIDrawCall.manager          = pan;
        uIDrawCall.useMerge         = true;
        return(uIDrawCall);
    }
Esempio n. 3
0
 static public int Create_s(IntPtr l)
 {
     try {
         UIPanel a1;
         checkType(l, 1, out a1);
         UnityEngine.Material a2;
         checkType(l, 2, out a2);
         UnityEngine.Texture a3;
         checkType(l, 3, out a3);
         UnityEngine.Shader a4;
         checkType(l, 4, out a4);
         var ret = UIDrawCall.Create(a1, a2, a3, a4);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 4
0
    private void FillAllDrawCalls()
    {
        for (Int32 i = 0; i < this.drawCalls.Count; i++)
        {
            UIDrawCall.Destroy(this.drawCalls[i]);
        }
        this.drawCalls.Clear();
        Material   material   = (Material)null;
        Texture    texture    = (Texture)null;
        Shader     shader     = (Shader)null;
        UIDrawCall uidrawCall = (UIDrawCall)null;
        Int32      num        = 0;

        if (this.mSortWidgets)
        {
            this.SortWidgets();
        }
        for (Int32 j = 0; j < this.widgets.Count; j++)
        {
            UIWidget uiwidget = this.widgets[j];
            if (uiwidget.isVisible && uiwidget.hasVertices)
            {
                Material material2   = uiwidget.material;
                Texture  mainTexture = uiwidget.mainTexture;
                Shader   shader2     = uiwidget.shader;
                if (material != material2 || texture != mainTexture || shader != shader2)
                {
                    if (uidrawCall != (UnityEngine.Object)null && uidrawCall.verts.size != 0)
                    {
                        this.drawCalls.Add(uidrawCall);
                        uidrawCall.UpdateGeometry(num);
                        uidrawCall.onRender = this.mOnRender;
                        this.mOnRender      = (UIDrawCall.OnRenderCallback)null;
                        num        = 0;
                        uidrawCall = (UIDrawCall)null;
                    }
                    material = material2;
                    texture  = mainTexture;
                    shader   = shader2;
                }
                if (material != (UnityEngine.Object)null || shader != (UnityEngine.Object)null || texture != (UnityEngine.Object)null)
                {
                    if (uidrawCall == (UnityEngine.Object)null)
                    {
                        uidrawCall            = UIDrawCall.Create(this, material, texture, shader);
                        uidrawCall.depthStart = uiwidget.depth;
                        uidrawCall.depthEnd   = uidrawCall.depthStart;
                        uidrawCall.panel      = this;
                    }
                    else
                    {
                        Int32 depth = uiwidget.depth;
                        if (depth < uidrawCall.depthStart)
                        {
                            uidrawCall.depthStart = depth;
                        }
                        if (depth > uidrawCall.depthEnd)
                        {
                            uidrawCall.depthEnd = depth;
                        }
                    }
                    uiwidget.drawCall = uidrawCall;
                    num++;
                    if (this.generateNormals)
                    {
                        uiwidget.WriteToBuffers(uidrawCall.verts, uidrawCall.uvs, uidrawCall.cols, uidrawCall.norms, uidrawCall.tans);
                    }
                    else
                    {
                        uiwidget.WriteToBuffers(uidrawCall.verts, uidrawCall.uvs, uidrawCall.cols, null, null);
                    }
                    if (uiwidget.mOnRender != null)
                    {
                        if (this.mOnRender == null)
                        {
                            this.mOnRender = uiwidget.mOnRender;
                        }
                        else
                        {
                            this.mOnRender = (UIDrawCall.OnRenderCallback)Delegate.Combine(this.mOnRender, uiwidget.mOnRender);
                        }
                    }
                }
            }
            else
            {
                uiwidget.drawCall = (UIDrawCall)null;
            }
        }
        if (uidrawCall != (UnityEngine.Object)null && uidrawCall.verts.size != 0)
        {
            this.drawCalls.Add(uidrawCall);
            uidrawCall.UpdateGeometry(num);
            uidrawCall.onRender = this.mOnRender;
            this.mOnRender      = (UIDrawCall.OnRenderCallback)null;
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Fill the geometry fully, processing all widgets and re-creating all draw calls.
    /// </summary>

    static public void Fill()
    {
        UIDrawCall.ClearAll();

        int        index = 0;
        UIPanel    pan   = null;
        Material   mat   = null;
        Texture    tex   = null;
        Shader     sdr   = null;
        UIDrawCall dc    = null;

        for (int i = 0; i < UIWidget.list.size;)
        {
            UIWidget w = UIWidget.list[i];

            if (w == null)
            {
                UIWidget.list.RemoveAt(i);
                continue;
            }

            if (w.isVisible)
            {
                UIPanel  pn = w.panel;
                Material mt = w.material;
                Texture  tx = w.mainTexture;
                Shader   sd = w.shader;

                if (pan != pn || mat != mt || tex != tx || sdr != sd)
                {
                    if (pan != null && mVerts.size != 0)
                    {
                        pan.SubmitDrawCall(dc);
                        dc = null;
                    }

                    pan = pn;
                    mat = mt;
                    tex = tx;
                    sdr = sd;
                }

                if (pan != null && (mat != null || sdr != null || tex != null))
                {
                    if (dc == null)
                    {
                        dc            = UIDrawCall.Create(index++, pan, mat, tex, sdr);
                        dc.depthStart = w.raycastDepth;
                        dc.depthEnd   = dc.depthStart;
                        dc.panel      = pan;
                    }
                    else
                    {
                        int rd = w.raycastDepth;
                        if (rd < dc.depthStart)
                        {
                            dc.depthStart = rd;
                        }
                        if (rd > dc.depthEnd)
                        {
                            dc.depthEnd = rd;
                        }
                    }

                    w.drawCall = dc;

                    if (pan.generateNormals)
                    {
                        w.WriteToBuffers(mVerts, mUvs, mCols, mNorms, mTans);
                    }
                    else
                    {
                        w.WriteToBuffers(mVerts, mUvs, mCols, null, null);
                    }
                }
            }
            else
            {
                w.drawCall = null;
            }
            ++i;
        }
        if (mVerts.size != 0)
        {
            pan.SubmitDrawCall(dc);
        }
    }
Esempio n. 6
0
    void FillAllDrawCalls()
    {
        for (int i = 0; i < drawCalls.Count; ++i)
        {
            UIDrawCall.Destroy(drawCalls[i]);
        }
        drawCalls.Clear();

        Material   mat   = null;
        Texture    tex   = null;
        Shader     sdr   = null;
        UIDrawCall dc    = null;
        int        count = 0;

#if OPTIMISE_NGUI_GC_ALLOC
        int verticesCount = 0;
#endif

        if (mSortWidgets)
        {
            SortWidgets();
        }

        for (int i = 0; i < widgets.Count; ++i)
        {
            UIWidget w = widgets[i];

            if (w.isVisible && w.hasVertices)
            {
                Material mt = w.material;

                if (onCreateMaterial != null)
                {
                    mt = onCreateMaterial(w, mt);
                }

                Texture tx = w.mainTexture;
                Shader  sd = w.shader;

                if (mat != mt || tex != tx || sdr != sd)
                {
#if OPTIMISE_NGUI_GC_ALLOC
                    if (dc != null && verticesCount != 0)
#else
                    if (dc != null && dc.verts.Count != 0)
#endif
                    {
                        drawCalls.Add(dc);
#if OPTIMISE_NGUI_GC_ALLOC
                        FillDrawCallBuffers(dc, verticesCount);
                        verticesCount = 0;
#endif
                        dc.UpdateGeometry(count);
                        dc.onRender = mOnRender;
                        mOnRender   = null;
                        count       = 0;
                        dc          = null;
                    }

                    mat = mt;
                    tex = tx;
                    sdr = sd;
                }

                if (mat != null || sdr != null || tex != null)
                {
                    if (dc == null)
                    {
                        dc                  = UIDrawCall.Create(this, mat, tex, sdr);
                        dc.depthStart       = w.depth;
                        dc.depthEnd         = dc.depthStart;
                        dc.panel            = this;
                        dc.onCreateDrawCall = onCreateDrawCall;
                    }
                    else
                    {
                        int rd = w.depth;
                        if (rd < dc.depthStart)
                        {
                            dc.depthStart = rd;
                        }
                        if (rd > dc.depthEnd)
                        {
                            dc.depthEnd = rd;
                        }
                    }

                    w.drawCall = dc;

                    ++count;
#if !OPTIMISE_NGUI_GC_ALLOC
                    if (generateNormals)
                    {
                        w.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans, generateUV2 ? dc.uv2 : null);
                    }
                    else
                    {
                        w.WriteToBuffers(dc.verts, dc.uvs, dc.cols, null, null, generateUV2 ? dc.uv2 : null);
                    }
#else
                    widgetsInDrawCall.Add(w);
                    verticesCount += w.geometry.verts.Count;
#endif

                    if (w.mOnRender != null)
                    {
                        if (mOnRender == null)
                        {
                            mOnRender = w.mOnRender;
                        }
                        else
                        {
                            mOnRender += w.mOnRender;
                        }
                    }
                }
            }
            else
            {
                w.drawCall = null;
            }
        }

#if OPTIMISE_NGUI_GC_ALLOC
        if (dc != null && verticesCount != 0)
#else
        if (dc != null && dc.verts.Count != 0)
#endif
        {
            drawCalls.Add(dc);
#if OPTIMISE_NGUI_GC_ALLOC
            FillDrawCallBuffers(dc, verticesCount);
#endif
            dc.UpdateGeometry(count);
            dc.onRender = mOnRender;
            mOnRender   = null;
        }
    }
Esempio n. 7
0
 // Token: 0x060004FE RID: 1278 RVA: 0x00030A6B File Offset: 0x0002EC6B
 public static UIDrawCall Create(UIPanel panel, Material mat, Texture tex, Shader shader)
 {
     return(UIDrawCall.Create(null, panel, mat, tex, shader));
 }
Esempio n. 8
0
	/// <summary>
	/// Fill the geometry fully, processing all widgets and re-creating all draw calls.
	/// </summary>

	void FillAllDrawCalls ()
	{
		for (int i = 0; i < drawCalls.Count; ++i)
			UIDrawCall.Destroy(drawCalls[i]);
		drawCalls.Clear();

		Material mat = null;
		Texture tex = null;
		Shader sdr = null;
		UIDrawCall dc = null;
		int count = 0;

		if (mSortWidgets) SortWidgets();

		for (int i = 0; i < widgets.Count; ++i)
		{
			UIWidget w = widgets[i];

			if (w.isVisible && w.hasVertices)
			{
				Material mt = w.material;
				Texture tx = w.mainTexture;
				Shader sd = w.shader;

				if (mat != mt || tex != tx || sdr != sd)
				{
					if (dc != null && dc.verts.size != 0)
					{
						drawCalls.Add(dc);
						dc.UpdateGeometry(count);
						dc.onRender = mOnRender;
						mOnRender = null;
						count = 0;
						dc = null;
					}

					mat = mt;
					tex = tx;
					sdr = sd;
				}

				if (mat != null || sdr != null || tex != null)
				{
					if (dc == null)
					{
						dc = UIDrawCall.Create(this, mat, tex, sdr);
						dc.depthStart = w.depth;
						dc.depthEnd = dc.depthStart;
						dc.panel = this;
					}
					else
					{
						int rd = w.depth;
						if (rd < dc.depthStart) dc.depthStart = rd;
						if (rd > dc.depthEnd) dc.depthEnd = rd;
					}

					w.drawCall = dc;

					++count;
					if (generateNormals) w.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans);
					else w.WriteToBuffers(dc.verts, dc.uvs, dc.cols, null, null);

					if (w.mOnRender != null)
					{
						if (mOnRender == null) mOnRender = w.mOnRender;
						else mOnRender += w.mOnRender;
					}
				}
			}
			else w.drawCall = null;
		}

		if (dc != null && dc.verts.size != 0)
		{
			drawCalls.Add(dc);
			dc.UpdateGeometry(count);
			dc.onRender = mOnRender;
			mOnRender = null;
		}
	}
Esempio n. 9
0
    private void FillAllDrawCalls()
    {
        for (int i = 0; i < drawCalls.Count; i++)
        {
            UIDrawCall.Destroy(drawCalls[i]);
        }
        drawCalls.Clear();
        Material   material   = null;
        Texture    texture    = null;
        Shader     shader     = null;
        UIDrawCall uIDrawCall = null;
        int        num        = 0;

        if (mSortWidgets)
        {
            SortWidgets();
        }
        for (int j = 0; j < widgets.Count; j++)
        {
            UIWidget uIWidget = widgets[j];
            if (uIWidget.isVisible && uIWidget.hasVertices)
            {
                Material material2   = uIWidget.material;
                Texture  mainTexture = uIWidget.mainTexture;
                Shader   shader2     = uIWidget.shader;
                if (material != material2 || texture != mainTexture || shader != shader2)
                {
                    if (uIDrawCall != null && uIDrawCall.verts.size != 0)
                    {
                        drawCalls.Add(uIDrawCall);
                        uIDrawCall.UpdateGeometry(num);
                        uIDrawCall.onRender = mOnRender;
                        mOnRender           = null;
                        num        = 0;
                        uIDrawCall = null;
                    }
                    material = material2;
                    texture  = mainTexture;
                    shader   = shader2;
                }
                if (material != null || shader != null || texture != null)
                {
                    if (uIDrawCall == null)
                    {
                        uIDrawCall            = UIDrawCall.Create(this, material, texture, shader);
                        uIDrawCall.depthStart = uIWidget.depth;
                        uIDrawCall.depthEnd   = uIDrawCall.depthStart;
                        uIDrawCall.panel      = this;
                    }
                    else
                    {
                        int depth = uIWidget.depth;
                        if (depth < uIDrawCall.depthStart)
                        {
                            uIDrawCall.depthStart = depth;
                        }
                        if (depth > uIDrawCall.depthEnd)
                        {
                            uIDrawCall.depthEnd = depth;
                        }
                    }
                    uIWidget.drawCall = uIDrawCall;
                    num++;
                    if (generateNormals)
                    {
                        uIWidget.WriteToBuffers(uIDrawCall.verts, uIDrawCall.uvs, uIDrawCall.cols, uIDrawCall.norms, uIDrawCall.tans);
                    }
                    else
                    {
                        uIWidget.WriteToBuffers(uIDrawCall.verts, uIDrawCall.uvs, uIDrawCall.cols, null, null);
                    }
                    if (uIWidget.mOnRender != null)
                    {
                        if (mOnRender == null)
                        {
                            mOnRender = uIWidget.mOnRender;
                        }
                        else
                        {
                            mOnRender = (UIDrawCall.OnRenderCallback)Delegate.Combine(mOnRender, uIWidget.mOnRender);
                        }
                    }
                }
            }
            else
            {
                uIWidget.drawCall = null;
            }
        }
        if (uIDrawCall != null && uIDrawCall.verts.size != 0)
        {
            drawCalls.Add(uIDrawCall);
            uIDrawCall.UpdateGeometry(num);
            uIDrawCall.onRender = mOnRender;
            mOnRender           = null;
        }
    }
Esempio n. 10
0
 public unsafe static long $Invoke5(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UIDrawCall.Create(Marshal.PtrToStringUni(*(IntPtr *)args), (UIPanel)GCHandledObjects.GCHandleToObject(args[1]), (Material)GCHandledObjects.GCHandleToObject(args[2]), (Texture)GCHandledObjects.GCHandleToObject(args[3]), (Shader)GCHandledObjects.GCHandleToObject(args[4]))));
 }
Esempio n. 11
0
 public unsafe static long $Invoke4(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UIDrawCall.Create(Marshal.PtrToStringUni(*(IntPtr *)args))));
 }
Esempio n. 12
0
 public unsafe static long $Invoke3(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(UIDrawCall.Create((UIPanel)GCHandledObjects.GCHandleToObject(*args), (Material)GCHandledObjects.GCHandleToObject(args[1]), (Texture)GCHandledObjects.GCHandleToObject(args[2]), (Shader)GCHandledObjects.GCHandleToObject(args[3]))));
 }
Esempio n. 13
0
    private void FillAllDrawCalls()
    {
        for (int i = 0; i < this.drawCalls.size; i++)
        {
            UIDrawCall.Destroy(this.drawCalls.buffer[i]);
        }
        this.drawCalls.Clear();
        Material   material   = null;
        Texture    texture    = null;
        Shader     shader     = null;
        UIDrawCall uIDrawCall = null;

        if (this.mSortWidgets)
        {
            this.SortWidgets();
        }
        for (int j = 0; j < this.widgets.size; j++)
        {
            UIWidget uIWidget = this.widgets.buffer[j];
            if (uIWidget.isVisible && uIWidget.hasVertices)
            {
                Material material2   = uIWidget.material;
                Texture  mainTexture = uIWidget.mainTexture;
                Shader   shader2     = uIWidget.shader;
                if (material != material2 || texture != mainTexture || shader != shader2)
                {
                    if (uIDrawCall != null && uIDrawCall.verts.size != 0)
                    {
                        this.drawCalls.Add(uIDrawCall);
                        uIDrawCall.UpdateGeometry();
                        uIDrawCall = null;
                    }
                    material = material2;
                    texture  = mainTexture;
                    shader   = shader2;
                }
                if (material != null || shader != null || texture != null)
                {
                    if (uIDrawCall == null)
                    {
                        uIDrawCall            = UIDrawCall.Create(this, material, texture, shader);
                        uIDrawCall.depthStart = uIWidget.depth;
                        uIDrawCall.depthEnd   = uIDrawCall.depthStart;
                        uIDrawCall.panel      = this;
                    }
                    else
                    {
                        int depth = uIWidget.depth;
                        if (depth < uIDrawCall.depthStart)
                        {
                            uIDrawCall.depthStart = depth;
                        }
                        if (depth > uIDrawCall.depthEnd)
                        {
                            uIDrawCall.depthEnd = depth;
                        }
                    }
                    uIWidget.drawCall = uIDrawCall;
                    if (this.generateNormals)
                    {
                        uIWidget.WriteToBuffers(uIDrawCall.verts, uIDrawCall.uvs, uIDrawCall.cols, uIDrawCall.norms, uIDrawCall.tans);
                    }
                    else
                    {
                        uIWidget.WriteToBuffers(uIDrawCall.verts, uIDrawCall.uvs, uIDrawCall.cols, null, null);
                    }
                }
            }
            else
            {
                uIWidget.drawCall = null;
            }
        }
        if (uIDrawCall != null && uIDrawCall.verts.size != 0)
        {
            this.drawCalls.Add(uIDrawCall);
            uIDrawCall.UpdateGeometry();
        }
    }
Esempio n. 14
0
    // fill geo fully, process all widgets and re-creat dcs
    void FillAllDrawCall()
    {
        // destroy dcs
        for (int i = 0; i < drawCalls.size; ++i)
        {
            UIDrawCall.Destroy(drawCalls.buffer[i]);
        }
        drawCalls.Clear();

        Material   mat = null;
        Texture    tex = null;
        Shader     sdr = null;
        UIDrawCall dc  = null;

        // sort widgets
        SortWidgets();

        // loop widgets
        for (int i = 0; i < widgets.size; ++i)
        {
            // 1.get component
            UIWidget w = widgets.buffer[i];

            if (w.isVisible) // && w.hasVertices)
            {
                Material mt = w.material;
                Texture  tx = w.mainTexture;
                Shader   sd = w.shader;

                // 2.判定dc:ABA, 相同component,连续depth,才一个dc
                if (mat != mt || tex != tx || sdr != sd)
                {
                    // 5.update dc' geo
                    if (dc != null && dc.verts.size != 0)
                    {
                        drawCalls.Add(dc);
                        dc.UpdateGeometry();
                        dc = null;
                    }

                    mat = mt;
                    tex = tx;
                    sdr = sd;
                }

                // 3.create dc
                if (mat != null || sdr != null || tex != null)
                {
                    if (dc == null)
                    {
                        dc            = UIDrawCall.Create(this, mat, tex, sdr);
                        dc.depthStart = w.depth;
                        dc.depthEnd   = dc.depthStart;
                        dc.panel      = this;
                    }
                    else
                    {
                        int rd = w.depth;
                        if (rd < dc.depthStart)
                        {
                            dc.depthStart = rd;
                        }
                        if (rd > dc.depthEnd)
                        {
                            dc.depthEnd = rd;
                        }
                    }

                    // 4.fill dc(多个连续widget‘ geo到一个dc)
                    w.drawCall = dc;
                    w.WriteToBuffers(dc.verts, dc.uvs, dc.cols, null, null);
                }
            }
            else
            {
                w.drawCall = null;
            }
        }

        if (dc != null && dc.verts.size != 0)
        {
            drawCalls.Add(dc);
            dc.UpdateGeometry();
        }
    }
Esempio n. 15
0
    // method-drawcall:
    void FillAllDrawCall()
    {
        for (int i = 0; i < drawCalls.size; ++i)
        {
            UIDrawCall.Destroy(drawCalls.buffer[i]);
        }
        drawCalls.Clear();

        Material   mat = null;
        Texture    tex = null;
        Shader     sdr = null;
        UIDrawCall dc  = null;

        for (int i = 0; i < widgets.size; ++i)
        {
            UIWidget w = widgets.buffer[i];

            if (w.isVisible)
            {
                Material mt = w.material;
                Texture  tx = w.mainTexture;
                Shader   sd = w.shader;

                if (mat != mt || tex != tx || sdr != sd)
                {
                    if (dc != null && dc.verts.size != 0)
                    {
                        drawCalls.Add(dc);
                        dc.UpdateGeometry();
                        dc = null;
                    }

                    mat = mt;
                    tex = tx;
                    sdr = sd;
                }

                if (mat != null || sdr != null || tex != null)
                {
                    if (dc == null)
                    {
                        dc            = UIDrawCall.Create(this, mat, tex, sdr);
                        dc.depthStart = w.depth;
                        dc.depthEnd   = c.depthStart;
                        dc.panel      = this;
                    }
                    else
                    {
                        int rd = w.depth;
                        if (rd < dc.depthStart)
                        {
                            dc.depthStart = rd;
                        }
                        if (rd > dc.depthEnd)
                        {
                            dc.depthEnd = rd;
                        }
                    }

                    w.drawCall = dc;
                    w.WriteToBuffer(dc.verts, dc.uvs, dc.cols, null, null);
                }
            }
            else
            {
                w.drawCall = null;
            }
        }

        if (dc != null && dc.verts.size != 0)
        {
            drawCalls.Add(dc);
            dc.UpdateGeometry();
        }
    }