public void BackupMeshColor(GameObject targetObj, bool bRecursively) { if (targetObj == null) { return; } if (bRecursively) { this.m_SavedMeshColor = NcEffectInitBackup.SAVE_TYPE.RECURSIVELY; } else { this.m_SavedMeshColor = NcEffectInitBackup.SAVE_TYPE.ONE; } if (this.m_SavedMeshColor == NcEffectInitBackup.SAVE_TYPE.RECURSIVELY) { this.m_MeshColorMeshFilters = targetObj.GetComponentsInChildren<MeshFilter>(true); this.m_MeshColorSaveValues = new Vector4[this.m_MeshColorMeshFilters.Length]; if (this.m_MeshColorMeshFilters == null || this.m_MeshColorMeshFilters.Length < 0) { return; } for (int i = 0; i < this.m_MeshColorMeshFilters.Length; i++) { this.m_MeshColorSaveValues[i] = this.GetMeshColor(this.m_MeshColorMeshFilters[i]); } } else { this.m_MeshColorMeshFilter = targetObj.GetComponent<MeshFilter>(); this.m_MeshColorSaveValue = this.GetMeshColor(this.m_MeshColorMeshFilter); } }
public void BackupMaterialColor(GameObject targetObj, bool bRecursively) { if (targetObj == null) { return; } if (bRecursively) { this.m_SavedMaterialColor = NcEffectInitBackup.SAVE_TYPE.RECURSIVELY; } else { this.m_SavedMaterialColor = NcEffectInitBackup.SAVE_TYPE.ONE; } Transform transform = targetObj.transform; if (this.m_SavedMaterialColor == NcEffectInitBackup.SAVE_TYPE.RECURSIVELY) { this.m_MaterialColorRenderers = transform.GetComponentsInChildren <Renderer>(true); this.m_MaterialColorColorNames = new string[this.m_MaterialColorRenderers.Length]; this.m_MaterialColorSaveValues = new Vector4[this.m_MaterialColorRenderers.Length]; for (int i = 0; i < this.m_MaterialColorRenderers.Length; i++) { Renderer renderer = this.m_MaterialColorRenderers[i]; this.m_MaterialColorColorNames[i] = NcEffectInitBackup.GetMaterialColorName(renderer.sharedMaterial); if (this.m_MaterialColorColorNames[i] != null) { this.m_MaterialColorSaveValues[i] = renderer.material.GetColor(this.m_MaterialColorColorNames[i]); } } } else { this.m_MaterialColorRenderer = transform.GetComponent <Renderer>(); if (this.m_MaterialColorRenderer != null) { this.m_MaterialColorColorName = NcEffectInitBackup.GetMaterialColorName(this.m_MaterialColorRenderer.sharedMaterial); if (this.m_MaterialColorColorName != null) { this.m_MaterialColorSaveValue = this.m_MaterialColorRenderer.material.GetColor(this.m_MaterialColorColorName); } } } }