Support > NGUI 3 Support

Useful stuff

(1/1)

ArenMook:
I've decided to create a sticky where I can bookmark topics that others may find useful. I'll keep adding stuff here (and you're welcome to reply to suggest other additions).

[*]Alpha-based hit detection
[*]Nicki's Depth Management system
[*]Improved Localization System
[*]How to make health bars
[*]Action Bar system
[*]Packed Font with Outline/Shadow
[*]Font using Alpha-tested magnification (Valve's approach)
[*]Atlas switching / DPI control
[*]Atlas switching
[*]NGUI & FingerGestures
[*]Sliced & tiled sprite
[*]Photoshop -> NGUI
[*]Scale UIRoot based on width as well as height
[*]HTML in NGUI
[*]Dynamic Font + Emoticons
[*]Easy Window transition functionality
[*]Minimap
[*]Add-ons for NGUI (most are third party)
[*]Repeat Button
[*]Pre-load dynamic font characters
[*]Grid/Table with alignment
[/list]

ArenMook:
If you want to dynamically alter a renderer's draw queue (Renderer or Particle System), you can use the following script:
using UnityEngine; public class SetRenderQueue : MonoBehaviour{        public int renderQueue = 3000;         Material mMat;         void Start ()        {                Renderer ren = renderer;                 if (ren == null)                {                        ParticleSystem sys = GetComponent<ParticleSystem>();                        if (sys != null) ren = sys.renderer;                }                 if (ren != null)                {                        mMat = new Material(ren.sharedMaterial);                        mMat.renderQueue = renderQueue;                        ren.material = mMat;                }        }         void OnDestroy () { if (mMat != null) Destroy(mMat); }}

gyd:

--- Quote from: ArenMook on December 28, 2013, 06:42:12 PM ---If you want to dynamically alter a renderer's draw queue (Renderer or Particle System), you can use the following script:
using UnityEngine; public class SetRenderQueue : MonoBehaviour{        public int renderQueue = 3000;         Material mMat;         void Start ()        {                Renderer ren = renderer;                 if (ren == null)                {                        ParticleSystem sys = GetComponent<ParticleSystem>();                        if (sys != null) ren = sys.renderer;                }                 if (ren != null)                {                        mMat = new Material(ren.sharedMaterial);                        mMat.renderQueue = renderQueue;                        ren.material = mMat;                }        }         void OnDestroy () { if (mMat != null) Destroy(mMat); }}
--- End quote ---

I wrote this before. if anyone wants to place a SFX in front/back of a widget, it's very easy to do that at runtime;

RenderQueueModifier rqm = obj.AddComponent<RenderQueueModifier>();
rqm.m_target = whichWidget;
rqm.m_type = RenderType.FRONT;

using UnityEngine;using System.Collections; public class RenderQueueModifier : MonoBehaviour{        public enum RenderType        {                FRONT,                BACK        }         public UIWidget m_target = null;        public RenderType m_type = RenderType.FRONT;         Renderer[] _renderers;        int _lastQueue = 0;         void Start ()        {                _renderers = GetComponentsInChildren<Renderer>();        }                void FixedUpdate() {                if( m_target == null || m_target.drawCall == null )                        return;                int queue = m_target.drawCall.renderQueue;                queue += m_type == RenderType.FRONT ? 1 : -1;                if( _lastQueue != queue )                {                        _lastQueue = queue;                         foreach( Renderer r in _renderers )                        {                                r.material.renderQueue = _lastQueue;                        }                }        }} 

Navigation

[0] Message Index

Go to full version