void Update()
    {
        if (0 < m_fStartDestroyTime)
        {
            if (0 < m_fSmoothDestroyTime)
            {
                if (m_bSmoothHide)
                {
                    float fRate = 1 - ((GetEngineTime() - m_fStartDestroyTime) / m_fSmoothDestroyTime);
                    if (fRate < 0)
                    {
                        fRate = 0;
                    }

                    // Recursively
                    Renderer[] rens = transform.GetComponentsInChildren <Renderer>(true);
                    for (int n = 0; n < rens.Length; n++)
                    {
                        Renderer ren     = rens[n];
                        string   colName = GetMaterialColorName(ren.material);

                        if (colName != null)
                        {
                            Color col = ren.material.GetColor(colName);
                            col.a = Mathf.Min(fRate, col.a);
                            ren.material.SetColor(colName, col);
                        }
                    }
                }
                if (m_fStartDestroyTime + m_fSmoothDestroyTime < GetEngineTime())
                {
                    AutoDestruct();
                }
            }
        }
        else
        {
            // Time
//          if (0 < m_fStartTime && m_fLifeTime != 0)
            if (0 < m_fStartTime)
            {
                if (m_fStartTime + m_fLifeTime <= GetEngineTime())
                {
                    StartDestroy();
                }
            }

            // event
            if (m_bEndNcCurveAnimation && m_NcCurveAnimation != null)
            {
                if (1 <= m_NcCurveAnimation.GetElapsedRate())
                {
                    StartDestroy();
                }
            }
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (0 < m_fStartDestroyTime)
        {
            if (0 < m_fSmoothDestroyTime)
            {
                if (m_bSmoothHide)
                {
                    float fAlphaRate = 1 - ((GetEngineTime() - m_fStartDestroyTime) / m_fSmoothDestroyTime);
                    if (fAlphaRate < 0)
                    {
                        fAlphaRate = 0;
                    }

                    if (m_bMeshFilterOnlySmoothHide)
                    {
                        // Recursively
                        MeshFilter[] meshFilters = transform.GetComponentsInChildren <MeshFilter>(true);
                        Color        color;
                        for (int n = 0; n < meshFilters.Length; n++)
                        {
                            Color[] colors = meshFilters[n].mesh.colors;
                            for (int c = 0; c < colors.Length; c++)
                            {
                                color     = colors[c];
                                color.a   = Mathf.Min(color.a, fAlphaRate);
                                colors[c] = color;
                            }
                            meshFilters[n].mesh.colors = colors;
                        }
                    }
                    else
                    {
                        // Recursively
                        Renderer[] rens = transform.GetComponentsInChildren <Renderer>(true);
                        for (int n = 0; n < rens.Length; n++)
                        {
                            Renderer ren     = rens[n];
                            string   colName = GetMaterialColorName(ren.sharedMaterial);

                            if (colName != null)
                            {
                                Color col = ren.material.GetColor(colName);
                                col.a = Mathf.Min(col.a, fAlphaRate);
                                ren.material.SetColor(colName, col);
                                //                              AddRuntimeMaterial(ren.material);
                            }
                        }
                    }
                }
                if (m_fStartDestroyTime + m_fSmoothDestroyTime < GetEngineTime())
                {
                    AutoDestruct();
                }
            }
        }
        else
        {
            // Time
            //          if (0 < m_fStartTime && m_fLifeTime != 0)
            if (0 < m_fStartTime)
            {
                if (m_fStartTime + m_fLifeTime <= GetEngineTime())
                {
                    StartDestroy();
                }
            }

            // event
            if (m_bEndNcCurveAnimation && m_NcCurveAnimation != null)
            {
                if (1 <= m_NcCurveAnimation.GetElapsedRate())
                {
                    StartDestroy();
                }
            }
        }
    }