void DrawMultiGUI() { var selves = new VerletTester[targets.Length]; for (var i = 0; i < targets.Length; ++i) { selves[i] = targets[i] as VerletTester; } if (GUILayout.Button("Build and Assign")) { for (var i = 0; i < selves.Length; ++i) { selves[i].BuildAndAssign(); if (!Application.isPlaying) { MyEditorUtility.DirtyObject(selves[i].gameObject); } } } }
public static void CheckDifferentPixels(ScenarioCharacterAssetGenerator source) { MyEditorUtility.ProgressBar("CheckDifferentPixels", progress => { var textures = source.DiffTextures; if (textures == null || textures.Length <= 1) { return; } //全てのテクスチャが同サイズであるかチェック var width = source.BaseTexture.width; var height = source.BaseTexture.height; for (int i = 0; i < textures.Length; i++) { if (textures[i].width != width || textures[i].height != height) { Debug.LogError($"サイズ違いのテクスチャ:{textures[i].name}"); return; } } //色差分チェック //色に違いがあった最大のRectを探す int left = int.MaxValue; int right = -1; int top = -1; int bottom = int.MaxValue; bool isDifferentColor(Color src, Texture2D[] tx, int x, int y) { for (int i = 0; i < tx.Length; i++) { var color = tx[i].GetPixel(x, y); if (src != color) { return(true); } } return(false); }; float progressMax = width * height; progress.Report(("ほげ", 0)); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { var color = textures[0].GetPixel(x, y); if (isDifferentColor(color, textures, x, y)) { if (x < left) { left = x; } if (x > right) { right = x; } if (y < bottom) { bottom = y; } if (y > top) { top = y; } } } } source.DiffRect = new RectInt(left, bottom, right - left + 1, top - bottom + 1); //BlockSizeに応じた調整 left -= (left % source.BlockSize); bottom -= (bottom % source.BlockSize); var w = right - left + 1; var wmod = w % source.BlockSize; w += (wmod == 0 ? 0 : source.BlockSize - wmod); var h = top - bottom + 1; var hmod = h % source.BlockSize; h += (hmod == 0 ? 0 : source.BlockSize - hmod); source.DiffRectAdjustedByBlockSize = new RectInt(left, bottom, w, h); });