본문 바로가기
게임 개발/Unity3D

[Unity | 유니티] NGUI와 ParticleSystem간 Depth 조정

by 불타는홍당무 2019. 9. 6.

ParticleSystem에 해당 스크립트를 추가하고 타 NGUI 컴포넌트처럼 Depth값을 조정하면 된다.

 

UIParticleWidget.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
[AddComponentMenu("NGUI/UI/NGUI-Particle Widget")]
public class UIParticleWidget : UIWidget
{
    protected Renderer m_Renderer;
    protected Material m_Mat;
 
    public override Material material
    {
        get
        {
            return m_Mat;
        }
 
        set
        {
            if (m_Mat != value)
            {
                RemoveFromPanel();
                m_Mat = value;
                MarkAsChanged();
            }
        }
    }
 
    protected override void OnEnable()
    {
        Init();
        base.OnEnable();
    }
 
    protected void Init()
    {
        if (null == m_Renderer)
        {
            m_Renderer = GetComponent<Renderer>();
        }
 
        if (null == m_Renderer)
        {
            return;
        }
 
        if (null == material)
        {
            if (false == Application.isPlaying)
            {
                material = m_Renderer.sharedMaterial;
                m_Renderer.sharedMaterial = material;
            }
            else
            {
                material = m_Renderer.material;
                m_Renderer.material = material;
            }
        }
    }
 
    private void OnWillRenderObject()
    {
        if (null != drawCall && drawCall.finalRenderQueue != material.renderQueue)
        {
            material.renderQueue = drawCall.finalRenderQueue;
        }
    }
 
    public override void OnFill(List<Vector3> verts, List<Vector2> uvs, List<Color> cols)
    {
        for (int i = 0; i < 4; i++)
        {
            verts.Add(Vector3.zero);
            uvs.Add(Vector2.zero);
            cols.Add(color);
        }
    }
}
cs