Author Topic: A strange problem about particles(android only, ios is ok)  (Read 2193 times)

Tonytian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Hi, when I use the following code to alter renderQueue for particles and Enable it, most UISprites/UITextures/UIlabel disappear(include the particles), only a small part of them left on screen
It exists only on android (iOS is ok)

I am so Confused...

  1.  
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class RenderQueueModifier : MonoBehaviour
  6. {
  7.     public enum RenderType
  8.     {
  9.         FRONT,
  10.         BACK
  11.     }
  12.  
  13.     public UIWidget m_target = null;
  14.     public RenderType m_type = RenderType.FRONT;
  15.  
  16.     Renderer[] _renderers;
  17.     int _lastQueue = 0;
  18.  
  19.     void Start ()
  20.     {
  21.         _renderers = GetComponentsInChildren<Renderer>();
  22.     }
  23.    
  24.     void FixedUpdate() {
  25.         if( m_target == null || m_target.drawCall == null )
  26.             return;
  27.         int queue = m_target.drawCall.renderQueue;
  28.         queue += m_type == RenderType.FRONT ? 1 : -1;
  29.         if( _lastQueue != queue )
  30.         {
  31.             _lastQueue = queue;
  32.  
  33.             foreach( Renderer r in _renderers )
  34.             {
  35.                 r.material.renderQueue = _lastQueue;
  36.             }
  37.         }
  38.     }
  39. }
  40.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: A strange problem about particles(android only, ios is ok)
« Reply #1 on: May 24, 2014, 04:14:48 PM »
FixedUpdate is for physics. It's not for modifying rendering. Use Update() for that.