Beispiel #1
0
 private Boolean FillDrawCall(UIDrawCall dc)
 {
     if (dc != (UnityEngine.Object)null)
     {
         dc.isDirty = false;
         Int32 num = 0;
         Int32 i   = 0;
         while (i < this.widgets.Count)
         {
             UIWidget uiwidget = this.widgets[i];
             if (uiwidget == (UnityEngine.Object)null)
             {
                 this.widgets.RemoveAt(i);
             }
             else
             {
                 if (uiwidget.drawCall == dc)
                 {
                     if (uiwidget.isVisible && uiwidget.hasVertices)
                     {
                         num++;
                         if (this.generateNormals)
                         {
                             uiwidget.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans);
                         }
                         else
                         {
                             uiwidget.WriteToBuffers(dc.verts, dc.uvs, dc.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;
                     }
                 }
                 i++;
             }
         }
         if (dc.verts.size != 0)
         {
             dc.UpdateGeometry(num);
             dc.onRender    = this.mOnRender;
             this.mOnRender = (UIDrawCall.OnRenderCallback)null;
             return(true);
         }
     }
     return(false);
 }
 private bool FillDrawCall(UIDrawCall dc)
 {
     if (dc != null)
     {
         dc.isDirty = false;
         int num = 0;
         int i   = 0;
         while (i < this.widgets.get_Count())
         {
             UIWidget uIWidget = this.widgets.get_Item(i);
             if (uIWidget == null)
             {
                 this.widgets.RemoveAt(i);
             }
             else
             {
                 if (uIWidget.drawCall == dc)
                 {
                     if (uIWidget.isVisible && uIWidget.hasVertices)
                     {
                         num++;
                         if (this.generateNormals)
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans);
                         }
                         else
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.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 = null;
                     }
                 }
                 i++;
             }
         }
         if (dc.verts.size != 0)
         {
             dc.UpdateGeometry(num);
             dc.onRender    = this.mOnRender;
             this.mOnRender = null;
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
 private bool FillDrawCall(UIDrawCall dc)
 {
     if (dc != null)
     {
         dc.isDirty = false;
         int num  = 0;
         int num2 = 0;
         while (num2 < widgets.Count)
         {
             UIWidget uIWidget = widgets[num2];
             if (uIWidget == null)
             {
                 widgets.RemoveAt(num2);
             }
             else
             {
                 if (uIWidget.drawCall == dc)
                 {
                     if (uIWidget.isVisible && uIWidget.hasVertices)
                     {
                         num++;
                         if (generateNormals)
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans);
                         }
                         else
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.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;
                     }
                 }
                 num2++;
             }
         }
         if (dc.verts.size != 0)
         {
             dc.UpdateGeometry(num);
             dc.onRender = mOnRender;
             mOnRender   = null;
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
	/// <summary>
	/// Fill the geometry for the specified draw call.
	/// </summary>

	bool FillDrawCall (UIDrawCall dc)
	{
		if (dc != null)
		{
			dc.isDirty = false;
			int count = 0;

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

				if (w == null)
				{
#if UNITY_EDITOR
					Debug.LogError("This should never happen");
#endif
					widgets.RemoveAt(i);
					continue;
				}

				if (w.drawCall == dc)
				{
					if (w.isVisible && w.hasVertices)
					{
						++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;
				}
				++i;
			}

			if (dc.verts.size != 0)
			{
				dc.UpdateGeometry(count);
				dc.onRender = mOnRender;
				mOnRender = null;
				return true;
			}
		}
		return false;
	}
Beispiel #5
0
 static public int UpdateGeometry(IntPtr l)
 {
     try {
         UIDrawCall   self = (UIDrawCall)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         self.UpdateGeometry(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #6
0
 private bool FillDrawCall(UIDrawCall dc)
 {
     if (dc != null)
     {
         dc.isDirty = false;
         int i = 0;
         while (i < this.widgets.size)
         {
             UIWidget uIWidget = this.widgets[i];
             if (uIWidget == null)
             {
                 this.widgets.RemoveAt(i);
             }
             else
             {
                 if (uIWidget.drawCall == dc)
                 {
                     if (uIWidget.isVisible && uIWidget.hasVertices)
                     {
                         if (this.generateNormals)
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans);
                         }
                         else
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.cols, null, null);
                         }
                     }
                     else
                     {
                         uIWidget.drawCall = null;
                     }
                 }
                 i++;
             }
         }
         if (dc.verts.size != 0)
         {
             dc.UpdateGeometry();
             return(true);
         }
     }
     return(false);
 }
Beispiel #7
0
    void Start()
    {
        GameObject drawCallObj = GameObject.Find("DrawCallObject");
        UIDrawCall drawCall    = drawCallObj.GetComponent <UIDrawCall>();

        drawCall.verts.buffer =
            new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 10, 0), new Vector3(10, 0, 0), new Vector3(10, 10, 0) };
        drawCall.verts.size = 4;

        drawCall.uvs.buffer =
            new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 0), new Vector2(1, 1) };
        drawCall.uvs.size = 4;

        drawCall.mIndices = new int[] { 0, 1, 2, 0, 1, 2 };

        drawCall.cols.buffer = new Color32[] { new Color32(255, 255, 255, 255), new Color32(255, 255, 255, 255), new Color32(255, 255, 255, 255), new Color32(255, 255, 255, 255) };
        drawCall.cols.size   = 4;

        drawCall.UpdateGeometry();
    }
    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;
        }
    }
    public bool FillDrawCall(UIDrawCall dc)
    {
        if (dc != null)
        {
            dc.isDirty = false;
            int count = 0;
#if OPTIMISE_NGUI_GC_ALLOC
            int verticesCount = 0;
#endif

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

                if (w == null)
                {
#if UNITY_EDITOR
                    Debug.LogError("This should never happen");
#endif
                    widgets.RemoveAt(i);
                    continue;
                }

                if (w.drawCall == dc)
                {
                    if (w.isVisible && w.hasVertices)
                    {
                        ++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;
                    }
                }
                ++i;
            }
#if !OPTIMISE_NGUI_GC_ALLOC
            if (dc.verts.Count != 0)
            {
#else
            if (verticesCount != 0)
            {
                FillDrawCallBuffers(dc, verticesCount);
#endif
                dc.UpdateGeometry(count);
                dc.onRender = mOnRender;
                mOnRender   = null;
                return(true);
            }
        }
        return(false);
    }
}
Beispiel #10
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;
		}
	}
Beispiel #11
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();
        }
    }
Beispiel #12
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();
        }
    }
Beispiel #13
0
 private bool FillDrawCall(UIDrawCall dc)
 {
     if (dc != null)
     {
         dc.isDirty = false;
         int num = 0;
         int i = 0;
         while (i < this.widgets.Count)
         {
             UIWidget uIWidget = this.widgets[i];
             if (uIWidget == null)
             {
                 this.widgets.RemoveAt(i);
             }
             else
             {
                 if (uIWidget.drawCall == dc)
                 {
                     if (uIWidget.isVisible && uIWidget.hasVertices)
                     {
                         num++;
                         if (this.generateNormals)
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.cols, dc.norms, dc.tans);
                         }
                         else
                         {
                             uIWidget.WriteToBuffers(dc.verts, dc.uvs, dc.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 = null;
                     }
                 }
                 i++;
             }
         }
         if (dc.verts.size != 0)
         {
             dc.UpdateGeometry(num);
             dc.onRender = this.mOnRender;
             this.mOnRender = null;
             return true;
         }
     }
     return false;
 }
Beispiel #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();
        }
    }
Beispiel #15
0
	/// <summary>
	/// Fill the geometry for the specified draw call.
	/// </summary>

	bool FillDrawCall (UIDrawCall dc)
	{
		if (dc != null)
		{
			dc.isDirty = false;
			if (dc.mUIParticleData != null)
			{
				dc.mUIParticleData.Destroy();
				dc.mUIParticleData = null;
			}

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

				if (w == null)
				{
#if UNITY_EDITOR
					Debug.LogError("This should never happen");
#endif
					widgets.RemoveAt(i);
					continue;
				}

				if (w.drawCall == dc)
				{
					if (w.isVisible && w.hasVertices)
					{
						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);
					}
					else if (w.isVisible && w.modelGameObject != null) //wym
					{
						if (dc.mUIParticleData != null)
							dc.mUIParticleData.Destroy();
						dc.mUIParticleData = new UIParticleData(w);
						dc.mUIParticleData.RebuildMaterials();
					}
					else w.drawCall = null;
				}
				++i;
			}

			if (dc.verts.size != 0)
			{
				dc.UpdateGeometry();
				return true;
			}
			if (dc.mUIParticleData != null)
			{
				return true;
			}
		}
		return false;
	}
Beispiel #16
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;
        }
    }
Beispiel #17
0
	/// <summary>
	/// Fill the geometry for the specified draw call.
	/// </summary>

	bool FillDrawCall (UIDrawCall dc)
	{
		if (dc != null)
		{
			dc.isDirty = false;

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

				if (w == null)
				{
#if UNITY_EDITOR
					Debug.LogError("This should never happen");
#endif
					widgets.RemoveAt(i);
					continue;
				}

				if (w.drawCall == dc)
				{
					if (w.isVisible && w.hasVertices)
					{
						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);
					}
					else w.drawCall = null;
				}
				++i;
			}

			if (dc.verts.size != 0)
			{
				dc.UpdateGeometry();
				return true;
			}
		}
		return false;
	}
Beispiel #18
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;
        }
    }