private static bool FillDataAndCheckResolving(Dictionary <Material, List <Mesh> > meshesWithMaterials, List <Mesh> meshesWithoutMaterials) { colorResolving = Resolving.Not; normalsResolving = Resolving.Not; uvResolving = Resolving.Not; bool anyHasColors = false; bool anyHasNormals = false; bool anyHasUVs = false; bool anyHasNotColors = false; bool anyHasNotNormals = false; bool anyHasNotUVs = false; HashSet <Transform> transforms = new HashSet <Transform>(); foreach (GameObject selected in Selection.gameObjects) { MeshFilter[] meshFilters = selected.GetComponentsInChildren <MeshFilter>(); foreach (var meshFilter in meshFilters) { if (transforms.Contains(meshFilter.transform)) { continue; } Material material = null; var mr = meshFilter.GetComponent <MeshRenderer>(); if (mr != null) { material = mr.sharedMaterial; } Mesh mesh = Instantiate(meshFilter.sharedMesh); HandleMesh(meshesWithMaterials, meshesWithoutMaterials, mesh, meshFilter.transform, material, transforms, ref anyHasNotNormals, ref anyHasNotColors, ref anyHasNotUVs, ref anyHasNormals, ref anyHasColors, ref anyHasUVs); } SkinnedMeshRenderer[] skinnedMeshRenderers = selected.GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (var skinnedMeshRenderer in skinnedMeshRenderers) { if (transforms.Contains(skinnedMeshRenderer.transform)) { continue; } Material material = skinnedMeshRenderer.sharedMaterial; Mesh mesh = BonesBaker.GetMeshFromSkinnedMeshRenderer(skinnedMeshRenderer); HandleMesh(meshesWithMaterials, meshesWithoutMaterials, mesh, skinnedMeshRenderer.transform, material, transforms, ref anyHasNotNormals, ref anyHasNotColors, ref anyHasNotUVs, ref anyHasNormals, ref anyHasColors, ref anyHasUVs); } } return(SetResolving(anyHasNormals, anyHasNotNormals, ref normalsResolving, "normals") && SetResolving(anyHasColors, anyHasNotColors, ref colorResolving, "colors") && SetResolving(anyHasUVs, anyHasNotUVs, ref uvResolving, "uvs")); }
private static void FillOrResolve <T>(T[] source, List <T> distanation, int expectedCount, Resolving resolvingLogic) { if (source.Length == 0 && resolvingLogic == Resolving.Create) { for (int i = 0; i < expectedCount; i++) { distanation.Add(default(T)); } } else { distanation.AddRange(source); } }
private static bool SetResolving(bool has, bool hasNot, ref Resolving resolving, string property) { if (has && hasNot) { var result = EditorUtility.DisplayDialogComplex("Simplest Mesh Baker", "Not all objects used " + property + ".", "Don't use " + property, //0 "Cancel", //1 "Create fake " + property //2 ); if (result == 1) { return(false); } resolving = result == 0 ? Resolving.Remove : Resolving.Create; } return(true); }
private RoAssembly TryFindAssemblyByRaisingResolveEvent(RoAssemblyName refName) { Debug.Assert(refName != null); Assembly assembly = Resolving?.Invoke(this, refName.ToAssemblyName()); if (assembly == null) { return(new RoExceptionAssembly(new FileNotFoundException(SR.Format(SR.FileNotFoundAssembly, refName.FullName)))); } if (!(assembly is RoAssembly roAssembly && roAssembly.Loader == this)) { throw new FileLoadException(SR.ExternalAssemblyReturnedByResolveHandler); } return(roAssembly); }
/// <summary> /// Occurs On <see cref="Resolving"/> event. /// </summary> /// <param name="e"></param> /// <see cref="IProblemSolver.Resolving"/> protected virtual void OnResolving(EventArgs e) { Resolving?.Invoke(this, e); }