// Property -------------------------------------------------------------------------
    public static NcDetachObject Create(GameObject parentObj, GameObject linkObject)
    {
        NcDetachObject deObj = parentObj.AddComponent <NcDetachObject>();

        deObj.m_LinkGameObject = linkObject;
        return(deObj);
    }
Exemple #2
0
    void Update()
    {
        if (m_bStartDetach == false)
        {
            m_bStartDetach = true;

            if (transform.parent != null)
            {
                m_ParentGameObject = transform.parent.gameObject;
                m_ncDetachObject   = NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
            }

            // Detach Parent
            GameObject parentObj = GetRootInstanceEffect();

            if (m_bFollowParentTransform)
            {
                m_OriginalPos.SetLocalTransform(transform);
                ChangeParent(parentObj.transform, transform, false, null);
                m_OriginalPos.CopyToLocalTransform(transform);
            }
            else
            {
                ChangeParent(parentObj.transform, transform, false, null);
            }

            if (m_bParentHideToStartDestroy == false)
            {
                StartDestroy();
            }
        }

        // Live time
        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;
                            if (colors.Length == 0)
                            {
                                colors = new Color[meshFilters[n].mesh.vertices.Length];
                                for (int c = 0; c < colors.Length; c++)
                                {
                                    colors[c] = Color.white;
                                }
                            }
                            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())
                {
                    Object.Destroy(gameObject);
                }
            }
        }
        else
        {
            if (m_bParentHideToStartDestroy)
            {
                if (m_ParentGameObject == null || IsActive(m_ParentGameObject) == false)
                {
                    StartDestroy();
                }
            }
        }

        // follow parent transform
        if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
        {
            NcTransformTool tmp = new NcTransformTool();
            tmp.SetTransform(m_OriginalPos);
            tmp.AddTransform(m_ParentGameObject.transform);
            tmp.CopyToLocalTransform(transform);
        }
    }
Exemple #3
0
	void Update()
	{
		if (m_bStartDetach == false)
		{
			m_bStartDetach = true;

			if (transform.parent != null)
			{
				m_ParentGameObject = transform.parent.gameObject;
				m_ncDetachObject	= NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
			}

			// Detach Parent
			GameObject	parentObj = GetRootInstanceEffect();

			if (m_bFollowParentTransform)
			{
				m_OriginalPos.SetLocalTransform(transform);
				ChangeParent(parentObj.transform, transform, false, null);
				m_OriginalPos.CopyToLocalTransform(transform);
			} else {
				ChangeParent(parentObj.transform, transform, false, null);
			}

			if (m_bParentHideToStartDestroy == false)
				StartDestroy();
		}

		// Live time
		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;
							if (colors.Length == 0)
							{
								colors = new Color[meshFilters[n].mesh.vertices.Length];
								for (int c = 0; c < colors.Length; c++)
									colors[c] = Color.white;
							}
							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())
					Object.Destroy(gameObject);
			}
		} else {
			if (m_bParentHideToStartDestroy)
				if (m_ParentGameObject == null || IsActive(m_ParentGameObject) == false)
					StartDestroy();
		}

		// follow parent transform
 		if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
 		{
 			NcTransformTool	tmp = new NcTransformTool();
 			tmp.SetTransform(m_OriginalPos);
 			tmp.AddTransform(m_ParentGameObject.transform);
 			tmp.CopyToLocalTransform(transform);
 		}
	}
 private void Update()
 {
     if (!this.m_bStartDetach)
     {
         this.m_bStartDetach = true;
         if (base.transform.parent != null)
         {
             this.m_ParentGameObject = base.transform.parent.gameObject;
             this.m_ncDetachObject   = NcDetachObject.Create(this.m_ParentGameObject, base.transform.gameObject);
         }
         GameObject rootInstanceEffect = NcEffectBehaviour.GetRootInstanceEffect();
         if (this.m_bFollowParentTransform)
         {
             this.m_OriginalPos.SetLocalTransform(base.transform);
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
             this.m_OriginalPos.CopyToLocalTransform(base.transform);
         }
         else
         {
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
         }
         if (!this.m_bParentHideToStartDestroy)
         {
             this.StartDestroy();
         }
     }
     if (0f < this.m_fStartDestroyTime)
     {
         if (0f < this.m_fSmoothDestroyTime)
         {
             if (this.m_bSmoothHide)
             {
                 float num = 1f - (NcEffectBehaviour.GetEngineTime() - this.m_fStartDestroyTime) / this.m_fSmoothDestroyTime;
                 if (num < 0f)
                 {
                     num = 0f;
                 }
                 if (this.m_bMeshFilterOnlySmoothHide)
                 {
                     MeshFilter[] componentsInChildren = base.transform.GetComponentsInChildren <MeshFilter>(true);
                     for (int i = 0; i < componentsInChildren.Length; i++)
                     {
                         Color[] array = componentsInChildren[i].mesh.colors;
                         if (array.Length == 0)
                         {
                             array = new Color[componentsInChildren[i].mesh.vertices.Length];
                             for (int j = 0; j < array.Length; j++)
                             {
                                 array[j] = Color.white;
                             }
                         }
                         for (int k = 0; k < array.Length; k++)
                         {
                             Color color = array[k];
                             color.a  = Mathf.Min(color.a, num);
                             array[k] = color;
                         }
                         componentsInChildren[i].mesh.colors = array;
                     }
                 }
                 else
                 {
                     Renderer[] componentsInChildren2 = base.transform.GetComponentsInChildren <Renderer>(true);
                     for (int l = 0; l < componentsInChildren2.Length; l++)
                     {
                         Renderer renderer          = componentsInChildren2[l];
                         string   materialColorName = NcEffectBehaviour.GetMaterialColorName(renderer.sharedMaterial);
                         if (materialColorName != null)
                         {
                             Color color2 = renderer.material.GetColor(materialColorName);
                             color2.a = Mathf.Min(color2.a, num);
                             renderer.material.SetColor(materialColorName, color2);
                         }
                     }
                 }
             }
             if (this.m_fStartDestroyTime + this.m_fSmoothDestroyTime < NcEffectBehaviour.GetEngineTime())
             {
                 UnityEngine.Object.Destroy(base.gameObject);
             }
         }
     }
     else if (this.m_bParentHideToStartDestroy && (this.m_ParentGameObject == null || !NcEffectBehaviour.IsActive(this.m_ParentGameObject)))
     {
         this.StartDestroy();
     }
     if (this.m_bFollowParentTransform && this.m_ParentGameObject != null && this.m_ParentGameObject.transform != null)
     {
         NcTransformTool ncTransformTool = new NcTransformTool();
         ncTransformTool.SetTransform(this.m_OriginalPos);
         ncTransformTool.AddTransform(this.m_ParentGameObject.transform);
         ncTransformTool.CopyToLocalTransform(base.transform);
     }
 }
Exemple #5
0
 private void Update()
 {
     if (!this.m_bStartDetach)
     {
         this.m_bStartDetach = true;
         if (base.transform.parent != null)
         {
             this.m_ParentGameObject = base.transform.parent.gameObject;
             NcDetachObject.Create(this.m_ParentGameObject, base.transform.gameObject);
         }
         GameObject rootInstanceEffect = NcEffectBehaviour.GetRootInstanceEffect();
         if (this.m_bFollowParentTransform)
         {
             this.m_OriginalPos.SetLocalTransform(base.transform);
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
             this.m_OriginalPos.CopyToLocalTransform(base.transform);
         }
         else
         {
             base.ChangeParent(rootInstanceEffect.transform, base.transform, false, null);
         }
         if (!this.m_bParentHideToStartDestroy)
         {
             this.StartDestroy();
         }
     }
     if (0f < this.m_fStartDestroyTime)
     {
         if (0f < this.m_fSmoothDestroyTime)
         {
             if (this.m_bSmoothHide)
             {
                 float num = 1f - (NcEffectBehaviour.GetEngineTime() - this.m_fStartDestroyTime) / this.m_fSmoothDestroyTime;
                 if (num < 0f)
                 {
                     num = 0f;
                 }
                 Renderer[] componentsInChildren = base.transform.GetComponentsInChildren <Renderer>(true);
                 for (int i = 0; i < componentsInChildren.Length; i++)
                 {
                     Renderer renderer          = componentsInChildren[i];
                     string   materialColorName = NcEffectBehaviour.GetMaterialColorName(renderer.material);
                     if (materialColorName != null)
                     {
                         Color color = renderer.material.GetColor(materialColorName);
                         color.a = Mathf.Min(num, color.a);
                         renderer.material.SetColor(materialColorName, color);
                     }
                 }
             }
             if (this.m_fStartDestroyTime + this.m_fSmoothDestroyTime < NcEffectBehaviour.GetEngineTime())
             {
                 DelegateProxy.GameDestory(base.gameObject);
             }
         }
     }
     else if (this.m_bParentHideToStartDestroy && (this.m_ParentGameObject == null || !NcEffectBehaviour.IsActive(this.m_ParentGameObject)))
     {
         this.StartDestroy();
     }
     if (this.m_bFollowParentTransform && this.m_ParentGameObject != null && this.m_ParentGameObject.transform != null)
     {
         NcTransformTool ncTransformTool = new NcTransformTool();
         ncTransformTool.SetTransform(this.m_OriginalPos);
         ncTransformTool.AddTransform(this.m_ParentGameObject.transform);
         ncTransformTool.CopyToLocalTransform(base.transform);
     }
 }
    public static void Create(GameObject parentObj, GameObject linkObject)
    {
        NcDetachObject ncDetachObject = parentObj.AddComponent <NcDetachObject>();

        ncDetachObject.m_LinkGameObject = linkObject;
    }
Exemple #7
0
    // Loop Function --------------------------------------------------------------------
    void Update()
    {
        if (m_bStartDetach == false)
        {
            m_bStartDetach = true;

            if (transform.parent != null)
            {
                m_ParentGameObject = transform.parent.gameObject;
                NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
            }

            // Detach Parent
            GameObject parentObj = GetRootInstanceEffect();

            if (m_bFollowParentTransform)
            {
                m_OriginalPos.SetLocalTransform(transform);
                ChangeParent(parentObj.transform, transform, false, null);
                m_OriginalPos.CopyToLocalTransform(transform);
            }
            else
            {
                ChangeParent(parentObj.transform, transform, false, null);
            }

            if (m_bParentHideToStartDestroy == false)
            {
                StartDestroy();
            }
        }

        // Live time
        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())
                {
                    Object.Destroy(gameObject);
                }
            }
        }
        else
        {
            if (m_bParentHideToStartDestroy)
            {
                if (m_ParentGameObject == null || IsActive(m_ParentGameObject) == false)
                {
                    StartDestroy();
                }
            }
        }

        // follow parent transform
        if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
        {
            NcTransformTool tmp = new NcTransformTool();
            tmp.SetTransform(m_OriginalPos);
            tmp.AddTransform(m_ParentGameObject.transform);
            tmp.CopyToLocalTransform(transform);
        }
    }
Exemple #8
0
 private void Update()
 {
     if (!this.m_bStartDetach)
     {
         this.m_bStartDetach = true;
         if (base.get_transform().get_parent() != null)
         {
             this.m_ParentGameObject = base.get_transform().get_parent().get_gameObject();
             NcDetachObject.Create(this.m_ParentGameObject, base.get_transform().get_gameObject());
         }
         GameObject rootInstanceEffect = NcEffectBehaviour.GetRootInstanceEffect();
         if (this.m_bFollowParentTransform)
         {
             this.m_OriginalPos.SetLocalTransform(base.get_transform());
             base.ChangeParent(rootInstanceEffect.get_transform(), base.get_transform(), false, null);
             this.m_OriginalPos.CopyToLocalTransform(base.get_transform());
         }
         else
         {
             base.ChangeParent(rootInstanceEffect.get_transform(), base.get_transform(), false, null);
         }
         if (!this.m_bParentHideToStartDestroy)
         {
             this.StartDestroy();
         }
     }
     if (0f < this.m_fStartDestroyTime)
     {
         if (0f < this.m_fSmoothDestroyTime)
         {
             if (this.m_bSmoothHide)
             {
                 float num = 1f - (NcEffectBehaviour.GetEngineTime() - this.m_fStartDestroyTime) / this.m_fSmoothDestroyTime;
                 if (num < 0f)
                 {
                     num = 0f;
                 }
                 if (this.m_bMeshFilterOnlySmoothHide)
                 {
                     MeshFilter[] componentsInChildren = base.get_transform().GetComponentsInChildren <MeshFilter>(true);
                     for (int i = 0; i < componentsInChildren.Length; i++)
                     {
                         Color[] colors = componentsInChildren[i].get_mesh().get_colors();
                         for (int j = 0; j < colors.Length; j++)
                         {
                             Color color = colors[j];
                             color.a  -= num;
                             colors[j] = color;
                         }
                         componentsInChildren[i].get_mesh().set_colors(colors);
                     }
                 }
                 else
                 {
                     Renderer[] componentsInChildren2 = base.get_transform().GetComponentsInChildren <Renderer>(true);
                     for (int k = 0; k < componentsInChildren2.Length; k++)
                     {
                         Renderer renderer          = componentsInChildren2[k];
                         string   materialColorName = NcEffectBehaviour.GetMaterialColorName(renderer.get_material());
                         if (materialColorName != null)
                         {
                             Color color2 = renderer.get_material().GetColor(materialColorName);
                             color2.a -= num;
                             renderer.get_material().SetColor(materialColorName, color2);
                         }
                     }
                 }
             }
             if (this.m_fStartDestroyTime + this.m_fSmoothDestroyTime < NcEffectBehaviour.GetEngineTime())
             {
                 Object.Destroy(base.get_gameObject());
             }
         }
     }
     else if (this.m_bParentHideToStartDestroy && (this.m_ParentGameObject == null || !NcEffectBehaviour.IsActive(this.m_ParentGameObject)))
     {
         this.StartDestroy();
     }
     if (this.m_bFollowParentTransform && this.m_ParentGameObject != null && this.m_ParentGameObject.get_transform() != null)
     {
         NcTransformTool ncTransformTool = new NcTransformTool();
         ncTransformTool.SetTransform(this.m_OriginalPos);
         ncTransformTool.AddTransform(this.m_ParentGameObject.get_transform());
         ncTransformTool.CopyToLocalTransform(base.get_transform());
     }
 }