Ejemplo n.º 1
0
 private void UpdateSelf()
 {
     this.mUpdateTime = RealTime.time;
     this.UpdateTransformMatrix();
     this.UpdateLayers();
     this.UpdateWidgets();
     if (this.mRebuild)
     {
         this.mRebuild = false;
         this.FillAllDrawCalls();
     }
     else
     {
         int i = 0;
         while (i < this.drawCalls.size)
         {
             UIDrawCall uIDrawCall = this.drawCalls.buffer[i];
             if (uIDrawCall.isDirty && !this.FillDrawCall(uIDrawCall))
             {
                 UIDrawCall.Destroy(uIDrawCall);
                 this.drawCalls.RemoveAt(i);
             }
             else
             {
                 i++;
             }
         }
     }
 }
Ejemplo n.º 2
0
    protected override void OnDisable()
    {
        Int32 i     = 0;
        Int32 count = this.drawCalls.Count;

        while (i < count)
        {
            UIDrawCall uidrawCall = this.drawCalls[i];
            if (uidrawCall != (UnityEngine.Object)null)
            {
                UIDrawCall.Destroy(uidrawCall);
            }
            i++;
        }
        this.drawCalls.Clear();
        UIPanel.list.Remove(this);
        this.mAlphaFrameID = -1;
        this.mMatrixFrame  = -1;
        if (UIPanel.list.Count == 0)
        {
            UIDrawCall.ReleaseAll();
            UIPanel.mUpdateFrame = -1;
        }
        base.OnDisable();
    }
    protected override void OnDisable()
    {
        int i     = 0;
        int count = this.drawCalls.get_Count();

        while (i < count)
        {
            UIDrawCall uIDrawCall = this.drawCalls.get_Item(i);
            if (uIDrawCall != null)
            {
                UIDrawCall.Destroy(uIDrawCall);
            }
            i++;
        }
        this.drawCalls.Clear();
        UIPanel.list.Remove(this);
        this.mAlphaFrameID = -1;
        this.mMatrixFrame  = -1;
        if (UIPanel.list.get_Count() == 0)
        {
            UIDrawCall.ReleaseAll();
            UIPanel.mUpdateFrame = -1;
        }
        base.OnDisable();
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Destroy all draw calls we've created when this script gets disabled.
    /// </summary>

    protected override void OnDisable()
    {
        UIDrawCall.Destroy(this);
        list.Remove(this);
        if (list.size == 0)
        {
            UIDrawCall.ReleaseAll();
        }
        base.OnDisable();
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Destroy all draw calls we've created when this script gets disabled.
    /// </summary>

    void OnDisable()
    {
        mParent = null;
        UIDrawCall.Destroy(this);
        list.Remove(this);
        if (list.size == 0)
        {
            UIDrawCall.ReleaseAll();
        }
    }
Ejemplo n.º 6
0
 static public int Destroy_s(IntPtr l)
 {
     try {
         UIDrawCall a1;
         checkType(l, 1, out a1);
         UIDrawCall.Destroy(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 7
0
    /// <summary>
    /// Main update function
    /// </summary>

    void LateUpdate()
    {
        // Only the very first panel should be doing the update logic
        if (list[0] != this)
        {
            return;
        }

        // Update all panels
        for (int i = 0; i < list.size; ++i)
        {
            UIPanel panel = list[i];
            panel.mUpdateTime = RealTime.time;
            panel.UpdateTransformMatrix();
            panel.UpdateLayers();
            panel.UpdateWidgets();
        }

        if (mRebuild)
        {
            Fill();
        }
        else
        {
            BetterList <UIDrawCall> dcs = UIDrawCall.activeList;

            for (int i = 0; i < dcs.size;)
            {
                UIDrawCall dc = dcs.buffer[i];

                if (dc.isDirty && !Fill(dc))
                {
                    UIDrawCall.Destroy(dc);
                    continue;
                }
                ++i;
            }
        }

        // Update the clipping rects
        for (int i = 0; i < list.size; ++i)
        {
            UIPanel panel = list[i];
            panel.UpdateDrawcalls();
        }
        mRebuild = false;
    }
Ejemplo n.º 8
0
    void OnDisable()
    {
        for (int i = 0; i < drawCalls.size; ++i)
        {
            UIDrawCall dc = drawCalls.buffer[i];
            if (dc != null)
            {
                UIDrawCall.Destroy(dc);
            }
        }
        drawCalls.Clear();

        list.Remove(this);

        if (list.size == 0)
        {
            UIDrawCall.ReleaseAll();
        }
    }
Ejemplo n.º 9
0
    private static void TrimDrawCalls(PrefabStage prefabStage, StageHandle stageHandleMain, BetterList <UIDrawCall> list, string identifier)
    {
        for (int i = list.size - 1; i >= 0; --i)
        {
            UIDrawCall dc = list[i];
            if (dc == null || !dc.gameObject.BelongsToCurrentStage(prefabStage, stageHandleMain))
            {
                list.RemoveAt(i);
                if (dc != null)
                {
                    UIDrawCall.Destroy(dc);
                }

                if (log)
                {
                    Debug.Log(string.Format("Removing {0} entry {1} from the {2} draw call list", dc == null ? "a null" : "an out of stage", i, identifier));
                }
            }
        }
    }
Ejemplo n.º 10
0
	/// <summary>
	/// Destroy all draw calls we've created when this script gets disabled.
	/// </summary>

	protected override void OnDisable ()
	{
		for (int i = 0, imax = drawCalls.Count; i < imax; ++i)
		{
			UIDrawCall dc = drawCalls[i];
			if (dc != null) UIDrawCall.Destroy(dc);
		}
		
		drawCalls.Clear();
		list.Remove(this);

		mAlphaFrameID = -1;
		mMatrixFrame = -1;
		
		if (list.Count == 0)
		{
			UIDrawCall.ReleaseAll();
			mUpdateFrame = -1;
		}
		base.OnDisable();
	}
Ejemplo n.º 11
0
 protected override void OnDisable()
 {
     for (int i = 0; i < this.drawCalls.size; i++)
     {
         UIDrawCall uIDrawCall = this.drawCalls.buffer[i];
         if (uIDrawCall != null)
         {
             UIDrawCall.Destroy(uIDrawCall);
         }
     }
     this.drawCalls.Clear();
     UIPanel.list.Remove(this);
     this.mAlphaFrameID = -1;
     this.mMatrixFrame  = -1;
     if (UIPanel.list.size == 0)
     {
         UIDrawCall.ReleaseAll();
         UIPanel.mUpdateFrame = -1;
     }
     base.OnDisable();
 }
Ejemplo n.º 12
0
 private void UpdateSelf()
 {
     this.mUpdateTime = RealTime.time;
     this.UpdateTransformMatrix();
     this.UpdateLayers();
     this.UpdateWidgets();
     if (this.mRebuild)
     {
         this.mRebuild = false;
         this.FillAllDrawCalls();
     }
     else
     {
         int i = 0;
         while (i < this.drawCalls.Count)
         {
             UIDrawCall uIDrawCall = this.drawCalls[i];
             if (uIDrawCall.isDirty && !this.FillDrawCall(uIDrawCall))
             {
                 UIDrawCall.Destroy(uIDrawCall);
                 this.drawCalls.RemoveAt(i);
             }
             else
             {
                 i++;
             }
         }
     }
     if (this.mUpdateScroll)
     {
         this.mUpdateScroll = false;
         UIScrollView component = base.GetComponent <UIScrollView>();
         if (component != null)
         {
             component.UpdateScrollbars();
         }
     }
 }
Ejemplo n.º 13
0
 private void UpdateSelf()
 {
     mUpdateTime = RealTime.time;
     UpdateTransformMatrix();
     UpdateLayers();
     UpdateWidgets();
     if (mRebuild)
     {
         mRebuild = false;
         FillAllDrawCalls();
     }
     else
     {
         int num = 0;
         while (num < drawCalls.Count)
         {
             UIDrawCall uIDrawCall = drawCalls[num];
             if (uIDrawCall.isDirty && !FillDrawCall(uIDrawCall))
             {
                 UIDrawCall.Destroy(uIDrawCall);
                 drawCalls.RemoveAt(num);
             }
             else
             {
                 num++;
             }
         }
     }
     if (mUpdateScroll)
     {
         mUpdateScroll = false;
         UIScrollView component = GetComponent <UIScrollView>();
         if (component != null)
         {
             component.UpdateScrollbars();
         }
     }
 }
Ejemplo n.º 14
0
    protected override void OnDisable()
    {
        int i = 0;

        for (int count = drawCalls.Count; i < count; i++)
        {
            UIDrawCall uIDrawCall = drawCalls[i];
            if (uIDrawCall != null)
            {
                UIDrawCall.Destroy(uIDrawCall);
            }
        }
        drawCalls.Clear();
        list.Remove(this);
        mAlphaFrameID = -1;
        mMatrixFrame  = -1;
        if (list.Count == 0)
        {
            UIDrawCall.ReleaseAll();
            mUpdateFrame = -1;
        }
        base.OnDisable();
    }
 private void DeleteRenderTexture()
 {
     //IL_0006: Unknown result type (might be due to invalid IL or missing references)
     //IL_001c: Unknown result type (might be due to invalid IL or missing references)
     //IL_002c: Unknown result type (might be due to invalid IL or missing references)
     if (renderCamera.get_targetTexture() != null)
     {
         renderCamera.get_targetTexture().DiscardContents();
         Object.Destroy(renderCamera.get_targetTexture());
         renderCamera.set_targetTexture(null);
         UIPanel panel = uiTexture.panel;
         uiTexture.mainTexture = null;
         if (uiTexture.drawCall != null)
         {
             uiTexture.drawCall.panel.drawCalls.Remove(uiTexture.drawCall);
             UIDrawCall.Destroy(uiTexture.drawCall);
             uiTexture.drawCall = null;
         }
         else if (panel != null)
         {
             panel.ForceUpDate();
         }
     }
 }
Ejemplo n.º 16
0
	/// <summary>
	/// Update the panel, all of its widgets and draw calls.
	/// </summary>

	void UpdateSelf ()
	{
		mUpdateTime = RealTime.time;

		UpdateTransformMatrix();
		UpdateLayers();
		UpdateWidgets();

		if (mRebuild)
		{
			mRebuild = false;
			FillAllDrawCalls();
		}
		else
		{
			for (int i = 0; i < drawCalls.Count; )
			{
				UIDrawCall dc = drawCalls[i];

				if (dc.isDirty && !FillDrawCall(dc))
				{
					UIDrawCall.Destroy(dc);
					drawCalls.RemoveAt(i);
					continue;
				}
				++i;
			}
		}

		if (mUpdateScroll)
		{
			mUpdateScroll = false;
			UIScrollView sv = GetComponent<UIScrollView>();
			if (sv != null) sv.UpdateScrollbars();
		}
	}
Ejemplo n.º 17
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;
        }
    }
Ejemplo n.º 18
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();
        }
    }
Ejemplo n.º 19
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;
		}
	}
Ejemplo n.º 20
0
 public unsafe static long $Invoke7(long instance, long *args)
 {
     UIDrawCall.Destroy((UIDrawCall)GCHandledObjects.GCHandleToObject(*args));
     return(-1L);
 }
Ejemplo n.º 21
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();
        }
    }
Ejemplo n.º 22
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();
        }
    }
Ejemplo n.º 23
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;
        }
    }
Ejemplo n.º 24
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;
        }
    }