private void AddTerrainMeshRenderer(GameObject go, List <MeshRenderer> meshRenderers) { if (IsSingleMeshTerrain(go)) { MeshRenderer mr = go.GetComponent <MeshRenderer>(); if (mr != null) { if (!meshRenderers.Contains(mr) && !m_allTerrainMeshRenderers.Contains(mr)) { meshRenderers.Add(mr); } } return; } if (IsMeshLODTerrain(go)) { LODGroup lg = go.GetComponent <LODGroup>(); foreach (LOD lod in lg.GetLODs()) { foreach (Renderer renderer in lod.renderers) { if (renderer != null && renderer.GetType() == typeof(MeshRenderer)) { MeshRenderer mr = (MeshRenderer)renderer; if (!meshRenderers.Contains(mr)) { meshRenderers.Add((MeshRenderer)mr); } } } } } }
private void RefreshLODGroup() { if (m_LODGroup == null) { return; } LOD[] L = m_LODGroup.GetLODs(); for (int i = 0; i < L.Length; ++i) { L[i].renderers = new Renderer[m_avatarPartSmrs.Count]; } int idx = 0; var e = m_avatarPartSmrs.GetEnumerator(); while (e.MoveNext()) { AvatarPart part = e.Current.Value; for (int i = 0; i < L.Length; ++i) { L[i].renderers[idx] = part.smrs[i]; } ++idx; } m_LODGroup.SetLODs(L); e.Dispose(); }
public void SelectLOD(int lodIndex) { GameObject[] gos = UnityEngine.GameObject.FindObjectsOfType <GameObject>(); List <GameObject> LOD = new List <GameObject>(); for (int i = 0; i < gos.Length; i++) { LODGroup group = gos[i].GetComponent <LODGroup>(); if (group == null) { continue; } LOD[] lods = group.GetLODs(); if (lods.Length < lodIndex) { continue; } Renderer[] renderers = lods[lodIndex].renderers; for (int j = 0; j < renderers.Length; j++) { LOD.Add(renderers[j].gameObject); } Selection.objects = LOD.ToArray(); } }
private void setUpInformation(LODGroup l) { lodGroup = l; lods = l.GetLODs(); dissolveMats = new Material[lods.Length]; renderersInLOD = new Renderer[lods.Length]; for (int i = 0; i < lods.Length; i++) { try{ renderersInLOD[i] = lods[i].renderers[0]; Material[] mats = renderersInLOD[i].materials; for (int j = 0; j < mats.Length; j++) { if (mats[j].name.Contains("leaves")) { dissolveMats[i] = renderersInLOD[i].materials[j]; } } }catch (IndexOutOfRangeException) { renderersInLOD[i] = null; dissolveMats[i] = null; } } listOfColliders = new List <MeshCollider>(); GetColliders(); }
private void Awake() { m_modelSkeleton = new ModelSkeleton(this.gameObject, m_rootBoneName); m_LODGroup = this.gameObject.GetComponent <LODGroup>(); if (m_LODGroup != null) { m_maxLODLevel = m_LODGroup.GetLODs().Length; } else { m_maxLODLevel = 1; } if (m_defaultParts != null) { if (m_defaultParts.Count > 0) { var e = m_defaultParts.GetEnumerator(); while (e.MoveNext()) { CreateDefaultPart(e.Current); } e.Dispose(); RefreshLODGroup(); } } }
void HierarchicalDown(GameObject parent) { LODGroup grp = parent.GetComponent <LODGroup>(); if (grp != null) { int expectMeshRenderer = 0; for (int i = 0; i < grp.lodCount; ++i) { expectMeshRenderer += grp.GetLODs()[i].renderers.Length; } int actualRenderer = 0; foreach (Transform t in grp.transform) { if (t.GetComponent <Renderer>() != null) { actualRenderer += 1; } } if (expectMeshRenderer != actualRenderer) { lodGroupWithUnaprented.Add(parent); } } else { for (int i = 0; i < parent.transform.childCount; ++i) { HierarchicalDown(parent.transform.GetChild(i).gameObject); } } }
public string EvaluateLODGroupName(LODGroup lodGroup, PrefabContext prefabContext) { if (lodGroup == null) { return(null); } var lods = lodGroup.GetLODs(); if (lods.Length == 0) { return(null); } var firstMesh = lods[0].renderers.FirstOrDefault(); if (firstMesh == null) { return(null); } var folder = ExportUtils.ReplaceExtension(ExportUtils.GetRelPathFromAsset(_engine.Options.Subfolder, firstMesh), ""); if (string.IsNullOrWhiteSpace(folder)) { folder = prefabContext.TempFolder; } return(ExportUtils.Combine(folder, ExportUtils.SafeFileName(_engine.DecorateName(ExportUtils.GetName(firstMesh))) + ".With" + lods.Length.ToString(CultureInfo.InvariantCulture) + "Lods.mdl")); }
// Use this for initialization void Start() { transPanelBrush = this.transform.Find("PanelBrush"); if (transPanelBrush != null) { InitBrushes(); } InitColors(); // transPanelTool = this.transform.Find("PanelTools"); if (transPanelTool == null) { return; } // InitBtnBrush(); Transform transBtnConfirm = transPanelTool.Find("BtnConfirm"); InitBtns("BtnClear", HandleBtnClear); InitBtns("BtnConfirm", HandlerBtnConfirm); // goCar = GameObject.FindGameObjectWithTag("Player"); if (goCar == null) { return; } LODGroup lodGroup = goCar.GetComponent <LODGroup>(); arrLOD = lodGroup.GetLODs(); // }
/// <summary> /// Loops through and copys lightmap index and offset from LOD0 to LOD1+2 /// </summary> void CopyLightmapSettings() { _lodGrp = GetComponent <LODGroup>(); LOD[] lods = _lodGrp.GetLODs(); _main = lods[0].renderers; _LOD1 = lods[1].renderers; _LOD2 = lods[2].renderers; int[] lmIndex = new int[_main.Length]; Vector4[] lmScaleOffset = new Vector4[_main.Length]; for (var i = 0; i < _main.Length; i++) { lmIndex[i] = _main[i].lightmapIndex; lmScaleOffset[i] = _main[i].lightmapScaleOffset; } for (var i = 0; i < _main.Length; i++) { _LOD1[i].lightmapIndex = lmIndex[i]; _LOD1[i].lightmapScaleOffset = lmScaleOffset[i]; _LOD2[i].lightmapIndex = lmIndex[i]; _LOD2[i].lightmapScaleOffset = lmScaleOffset[i]; } }
// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.A)) { lods = lodGroup.GetLODs(); } }
void OnGUI() { GUILayout.BeginHorizontal(); value = EditorGUILayout.Slider(value, 0, 1); PlayerPrefs.SetFloat("LOD Value", value); if (GUILayout.Button("设置")) { foreach (var it in Selection.gameObjects) { LODGroup lod = it.GetComponent <LODGroup>(); if (lod != null) { LOD[] lods = lod.GetLODs(); if (lods.Length >= 2) { lods[1].screenRelativeTransitionHeight = value; } lod.SetLODs(lods); } } } GUILayout.EndHorizontal(); }
/// <summary> /// Render a gameobject hierarchy. In case of LOD use the one with the specified level /// </summary> /// <param name="go"></param> /// <param name="sourceLODLevel"></param> public static void RenderGameObjectNow(GameObject go, int sourceLODLevel) { GameObject root = go; LODGroup lodGroup = go.GetComponent <LODGroup>(); if (lodGroup && lodGroup.lodCount > 0) { root = lodGroup.GetLODs()[sourceLODLevel].renderers[0].gameObject; } MeshRenderer[] renderers = root.GetComponentsInChildren <MeshRenderer>(); for (int i = 0; i < renderers.Length; i++) { MeshFilter meshFilter = renderers[i].gameObject.GetComponent <MeshFilter>(); if (meshFilter) { Matrix4x4 matrix = Matrix4x4.TRS( renderers[i].transform.position, renderers[i].transform.rotation, renderers[i].transform.lossyScale); Mesh mesh = meshFilter.sharedMesh; for (int j = 0; j < renderers[i].sharedMaterials.Length; j++) { Material material = renderers[i].sharedMaterials[j]; material.SetPass(0); Graphics.DrawMeshNow(mesh, matrix, j); } } } }
/// <summary> /// Postprocesses materials while you are importing a SpeedTree 8 asset. Call from OnPostprocessSpeedTree in a MaterialPostprocessor. /// </summary> /// <param name="speedtree">The GameObject Unity creates from this imported SpeedTree.</param> /// <param name="stImporter">The asset importer used to import this SpeedTree asset.</param> /// <param name="finalizer">Render pipeline-specific material finalizer.</param> public static void PostprocessSpeedTree8Materials(GameObject speedtree, SpeedTreeImporter stImporter, MaterialFinalizer finalizer = null) { LODGroup lg = speedtree.GetComponent <LODGroup>(); LOD[] lods = lg.GetLODs(); for (int l = 0; l < lods.Length; l++) { LOD lod = lods[l]; bool isBillboard = stImporter.hasBillboard && (l == lods.Length - 1); int wq = Mathf.Min(stImporter.windQualities[l], stImporter.bestWindQuality); foreach (Renderer r in lod.renderers) { // Override default motion vector generation mode pending // proper motion vector integration in SRPs. r.motionVectorGenerationMode = MotionVectorGenerationMode.Camera; foreach (Material m in r.sharedMaterials) { float cutoff = stImporter.alphaTestRef; ImportNewSpeedTree8Material(m, wq, isBillboard); if (finalizer != null) { finalizer(m); } } } } }
/// <summary> /// Updates the material of the station depending on its state. /// </summary> /// <param name="isOutOfService">True if the station is out of service.</param> public void UpdateStationMaterial(bool isOutOfService) { LODGroup lodgroup = this.gameObject.GetComponent <LODGroup>(); LOD[] lods; if (lodgroup != null && materialForOpenStation != null && materialForCloseStation != null) { lods = lodgroup.GetLODs(); foreach (LOD L in lods) { Renderer[] renderers = L.renderers; foreach (Renderer R in renderers) { if (!isOutOfService) { R.material = materialForOpenStation; } else { R.material = materialForCloseStation; } } } } }
void SetCullingPercents() { if (cullPercent > 1.0f) { cullPercent = 1.0f; } if (cullPercent < 0.0f) { cullPercent = 0.0f; } if (Selection.objects == null) { Debug.Log("Nothing Selected!"); return; } foreach (GameObject g in Selection.objects) { if (g.GetComponent <LODGroup>() == null) { return; } LODGroup group = g.GetComponent <LODGroup>(); LOD[] lods = group.GetLODs(); Renderer[] renderers = lods[0].renderers; lods[0] = new LOD(cullPercent, renderers); group.SetLODs(lods); group.RecalculateBounds(); } }
/// <summary> /// Configure lighting for all MeshRenderers in LODGroup /// </summary> /// <param name="regenerate">When true, overwrite existing secondary UVs</param> /// <param name="keepUnused">When true, remove unused secondary UVs</param> public static void ConfigureLODGroup(LODGroup lodGroup, bool regenerate = false, bool keepUnused = false) { // TODO: Check if group is static - if not do not generate charts // QUESTION: Should the renderers be checked? The group GameObject itself? // Only the first level of detail uses charts var lods = lodGroup.GetLODs(); foreach (var renderer in lods[0].renderers) { var meshRenderer = renderer as MeshRenderer; if (!meshRenderer) { continue; } ConvertToLightCharts(meshRenderer, regenerate); } for (var l = 1; l < lods.Length; ++l) { foreach (var renderer in lods[1].renderers) { var meshRenderer = renderer as MeshRenderer; if (!meshRenderer) { continue; } ConvertToLightProbes(meshRenderer, keepUnused); } } }
public OutlineData(GameObject parent, Color color, OutlinePrepassType outlinePrepassType) { this.parent = parent; List <Renderer> cacheRenderers = new List <Renderer>(); LODGroup lODGroup = parent.GetComponent <LODGroup>(); if (lODGroup != null) { LOD[] lODs = lODGroup.GetLODs(); cacheRenderers.AddRange(lODs[0].renderers); } else { cacheRenderers.AddRange(parent.GetComponentsInChildren <SkinnedMeshRenderer>()); } cacheRenderers.AddRange(parent.GetComponentsInChildren <MeshRenderer>()); cacheRenderers.AddRange(parent.GetComponentsInChildren <SpriteRenderer>()); renderers = cacheRenderers.ToArray(); this.color = color; this.outlinePrepassType = outlinePrepassType; UpdatePrepassMaterial(); }
public static Bounds GetBounds(this LODGroup lodGroup) { if (lodGroup.GetLODs().Length == 0) { return(new Bounds(Vector3.zero, Vector3.zero)); } LOD lod = lodGroup.GetLODs().First(); Bounds lodBounds = lod.renderers[0].bounds; for (int i = 0; i < lod.renderers.Length; ++i) { lodBounds.Encapsulate(lod.renderers[i].bounds); } return(lodBounds); }
bool CheckMeshAndLOD(GameObject obj) { Transform parentObj; if (obj.GetComponent <MeshFilter>() == null && obj.GetComponent <LODGroup>() == null) { return(false); } if (obj.activeInHierarchy == false) { return(false); Debug.LogWarning(obj.name + " set active = false", obj); } if (PrefabUtility.GetPrefabParent(obj) == null) { Debug.LogWarning(obj.name + " prefab = null", obj); return(false); } if (obj.GetComponent <MeshFilter>() != null) { parentObj = obj.transform.parent; if (parentObj != null) { if (obj.transform.parent.gameObject.GetComponent <LODGroup>() != null) { return(false); } } } if (obj.GetComponent <LODGroup>() != null) { LODGroup gLOD = obj.GetComponent <LODGroup>(); for (int g = 0; g < gLOD.GetLODs().Count(); g++) { LOD checkLOD = gLOD.GetLODs() [g]; if (checkLOD.renderers.Length == 0 || checkLOD.renderers[0] == null) { Debug.LogWarning(obj.name + " LOD " + g + " = null", obj); return(false); } } } return(true); }
// Token: 0x06001C98 RID: 7320 RVA: 0x0009B8FC File Offset: 0x00099CFC protected void applyDefaultLODs(LODGroup lod, bool fade) { LOD[] lods = lod.GetLODs(); lods[0].screenRelativeTransitionHeight = ((!fade) ? 0.6f : 0.7f); lods[1].screenRelativeTransitionHeight = ((!fade) ? 0.4f : 0.5f); lods[2].screenRelativeTransitionHeight = 0.15f; lods[3].screenRelativeTransitionHeight = 0.03f; lod.SetLODs(lods); }
public static int GetCurrentLOD(this LODGroup lodGroup, Camera camera = null) { LOD[] lods = lodGroup.GetLODs(); float relativeHeight = lodGroup.GetRelativeHeight(camera ?? Camera.current); int lodIndex = GetCurrentLOD(lods, lodGroup.GetMaxLOD(), relativeHeight, camera); return(lodIndex); }
/// <summary> /// Render a game object using DrawMesh. /// </summary> /// <param name="gameObject"></param> /// <param name="sourceLODLevel"></param> public static void RenderGameObject(GameObject gameObject, int sourceLODLevel) { GameObject[] roots = new GameObject[] { gameObject }; LODGroup lodGroup = gameObject.GetComponent <LODGroup>(); if (lodGroup && lodGroup.lodCount > 0) { // considering submeshes as well roots = new GameObject[lodGroup.GetLODs()[sourceLODLevel].renderers.Length]; for (int i = 0; i < roots.Length; i++) { roots[i] = lodGroup.GetLODs()[sourceLODLevel].renderers[i].gameObject; } } foreach (GameObject root in roots) { MeshRenderer[] renderers = root.GetComponentsInChildren <MeshRenderer>(); for (int i = 0; i < renderers.Length; i++) { MeshFilter meshFilter = renderers[i].gameObject.GetComponent <MeshFilter>(); if (meshFilter) { Matrix4x4 matrix = Matrix4x4.TRS( renderers[i].transform.position, renderers[i].transform.rotation, renderers[i].transform.lossyScale); Mesh mesh = meshFilter.sharedMesh; for (int j = 0; j < renderers[i].sharedMaterials.Length; j++) { Material material = renderers[i].sharedMaterials[j]; material.SetPass(0); // TODO: use this in later Unity versions: https://docs.unity3d.com/2021.2/Documentation/ScriptReference/Graphics.RenderMesh.html Graphics.DrawMesh(mesh, matrix, material, 0); } } } } }
private static void AddAI(int index) { var obj = Selection.activeGameObject; LODGroup g = obj.GetComponent <LODGroup> (); if (g == null) { return; } var lods = g.GetLODs(); matDic.Clear(); var rs = lods [index].renderers; foreach (var r in rs) { matDic.Add(r, r.sharedMaterial); ReplaceMat(r); } AmplifyImpostor ai = obj.GetComponent <AmplifyImpostor> (); if (ai == null) { ai = obj.AddComponent <AmplifyImpostor> (); } ai.Renderers = rs; ImpostorsAssist assist = obj.GetComponentInChildren <ImpostorsAssist> (); if (assist == null) { var prefab = AssetDatabase.LoadAssetAtPath <Object> ("Assets/Artist/TARD/LSY/ImpostorsManager/Prefabs/Assist.prefab"); var assistObj = PrefabUtility.InstantiatePrefab(prefab) as GameObject; assistObj.transform.parent = obj.transform; assistObj.transform.localPosition = Vector3.zero; assistObj.transform.localRotation = Quaternion.identity; assistObj.transform.localScale = Vector3.one; foreach (var r in rs) { r.transform.parent = assistObj.transform; } } BillboardRotationInitializer rotateInit = obj.GetComponent <BillboardRotationInitializer> (); if (rotateInit == null) { rotateInit = obj.AddComponent <BillboardRotationInitializer> (); } }
static void SetLODGroup_RefHeight(LODGroup group, List <float> rHeights) { var lods = group.GetLODs(); for (int i = 0; i < lods.Length; i++) { lods [i].screenRelativeTransitionHeight = rHeights[i]; } group.SetLODs(lods); }
public void CreateLodGroupColliders(LODGroup lodGroup, Transform parentT) { var lodGroupGO = new GameObject("L_" + lodGroup.name); Transform lodGroupT = lodGroupGO.transform; lodGroupT.parent = parentT; LOD[] lods = lodGroup.GetLODs(); bool meshColliderCreated = false; for (int i = 0; i < lods.Length; i++) { LOD lod = lods[i]; LodLevel lodLevel = new LodLevel(); Renderer[] rs = lod.renderers; for (int j = 0; j < rs.Length; j++) { Renderer r = rs[j]; GameObject go = r.gameObject; if (r.enabled && go.activeInHierarchy) { MeshFilter mf = go.GetComponent <MeshFilter>(); if (mf == null) { continue; } Mesh mesh = mf.sharedMesh; if (mesh == null) { continue; } meshColliderCreated = true; MeshCollider mc = CreateMeshCollider(mf, lodGroupT, "L" + i + "_"); lodLevel.colliders.Add(mc); lodLevel.gos.Add(mc.gameObject); lodInfoLookup.Add(mc, this); lodGroupMeshes.Add(mesh); } } lodLevels.Add(lodLevel); } if (meshColliderCreated) { lodInfos.Add(this); } }
/// <summary> /// Return an input data structure containing mesh data that needs to be /// uploaded from the given inputObject. /// Supports child gameobjects with meshes from the given inputObject. /// </summary> /// <param name="inputObject">GameObject containing mesh components</param> /// <returns>A valid input data strcuture containing mesh data</returns> public HEU_InputDataMeshes GenerateMeshDatasFromGameObject(GameObject inputObject, bool bExportColliders = false) { HEU_InputDataMeshes inputMeshes = new HEU_InputDataMeshes(); inputMeshes._inputObject = inputObject; LODGroup lodGroup = inputObject.GetComponent<LODGroup>(); if (lodGroup != null) { inputMeshes._hasLOD = true; LOD[] lods = lodGroup.GetLODs(); for (int i = 0; i < lods.Length; ++i) { if (lods[i].renderers != null && lods[i].renderers.Length > 0) { GameObject childGO = lods[i].renderers[0].gameObject; HEU_InputDataMesh meshData = CreateSingleMeshData(childGO, bExportColliders); if (meshData != null) { meshData._LODScreenTransition = lods[i].screenRelativeTransitionHeight; inputMeshes._inputMeshes.Add(meshData); } } } } else { inputMeshes._hasLOD = false; // Create a HEU_InputDataMesh for each gameobject with a MeshFilter (including children) MeshFilter[] meshFilters = inputObject.GetComponentsInChildren<MeshFilter>(); foreach (MeshFilter filter in meshFilters) { HEU_InputDataMesh meshData = CreateSingleMeshData(filter.gameObject, bExportColliders); if (meshData != null) { inputMeshes._inputMeshes.Add(meshData); } } SkinnedMeshRenderer[] skinnedMeshRenderers = inputObject.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer skinnedMeshRend in skinnedMeshRenderers) { HEU_InputDataMesh meshData = CreateSingleMeshData(skinnedMeshRend.gameObject, bExportColliders); if (meshData != null) { inputMeshes._inputMeshes.Add(meshData); } } } return inputMeshes; }
void OnEnable() { lodGroupSetup = (LODGroupSetup)target; LODGroup lodGroup = lodGroupSetup.lodGroup; oldLods = lodGroup.GetLODs(); animateCrossFadingOld = lodGroup.animateCrossFading; fadeModeOld = lodGroup.fadeMode; UnityEditor.EditorApplication.update += MyUpdate; }
/// <summary> /// Loops through and copies light map index and offset from LOD0 to LOD1+2 /// </summary> void CopyLightmapSettings() { _lodGrp = GetComponent <LODGroup>(); var lods = _lodGrp.GetLODs(); _main = lods[0].renderers; for (var i = 1; i < lods.Length; i++) { switch (i) { case 1: _lod1 = lods[i].renderers; break; case 2: _lod2 = lods[i].renderers; break; case 3: _lod3 = lods[i].renderers; break; } } var lmIndex = new int[_main.Length]; var lmScaleOffset = new Vector4[_main.Length]; for (var i = 0; i < _main.Length; i++) { lmIndex[i] = _main[i].lightmapIndex; lmScaleOffset[i] = _main[i].lightmapScaleOffset; } for (var i = 0; i < _main.Length; i++) { #pragma warning disable _lod1[i].lightmapIndex = lmIndex[i]; _lod1[i].lightmapScaleOffset = lmScaleOffset[i]; if (!_lod2[i]) { continue; } _lod2[i].lightmapIndex = lmIndex[i]; _lod2[i].lightmapScaleOffset = lmScaleOffset[i]; if (!_lod3[i]) { continue; } _lod3[i].lightmapIndex = lmIndex[i]; _lod3[i].lightmapScaleOffset = lmScaleOffset[i]; #pragma warning restore } }
public override void OnBuildChunk(ChunkDataContext context) { var writeCount = 0; var data = new LiveMesh((context.faceCount / 6) * 16, (context.faceCount / 6) * 24); foreach (VoxelPrimitive it in context.model.GetEnumerator(this.material.GetInstanceID())) { Vector3 pos, scale; it.GetTranslateScale(out pos, out scale); OnBuildBlock(ref data, ref writeCount, pos, scale, it.faces); } if (data.indices.Length > 0) { var actors = new GameObject(this.name); actors.isStatic = this.gameObject.isStatic; actors.tag = gameObject.tag; actors.layer = this.gameObject.layer; actors.transform.parent = context.parent.transform; actors.transform.position = context.parent.transform.position; var mesh = data.mesh; actors.AddComponent <MeshFilter>().mesh = mesh; if (_renderer != null) { var clone = actors.AddComponent <MeshRenderer>(); clone.material = _renderer.material; clone.receiveShadows = _renderer.receiveShadows; clone.shadowCastingMode = _renderer.shadowCastingMode; if (_lodGroup != null) { var lods = _lodGroup.GetLODs(); for (int i = 0; i < lods.Length; i++) { if (lods[i].renderers.Length > 0) { lods[i].renderers[0] = clone; } } actors.AddComponent <LODGroup>().SetLODs(lods); } } if (_meshCollider && _meshCollider.enabled) { var meshCollider = actors.AddComponent <MeshCollider>(); meshCollider.sharedMesh = _meshCollider.sharedMesh ? _meshCollider.sharedMesh : mesh; meshCollider.material = _meshCollider.material; } } }
private bool CompareLODs(LODGroup a, LODGroup b) { if (a.GetLODs() == null || b.GetLODs() == null || a.GetLODs().Length != b.GetLODs().Length) { return false; } MeshFilter[] componentsInChildren = a.GetComponentsInChildren<MeshFilter>(); MeshFilter[] componentsInChildren2 = b.GetComponentsInChildren<MeshFilter>(); if (componentsInChildren.Length != componentsInChildren2.Length) { return false; } for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].sharedMesh != componentsInChildren2[i].sharedMesh) { return false; } } return true; }