public void OnArtClicked() { canColor = true; isChoosing = true; artChoosingPopup.SetActive(true); currentSprite.sprite = Resources.Load <Sprite>($"PixelArts/{PlayerPrefs.GetString("CurrentArt")}"); List <Color> colors = new List <Color>(); float v; float c; Color[,] pixelArt = DataController.ReadImageByPixels(PlayerPrefs.GetString("CurrentArt"), out v, out c); for (int x = 0; x != pixelArt.GetLongLength(0); x++) { for (int y = 0; y != pixelArt.GetLongLength(1); y++) { if (pixelArt[x, y] == Color.clear) { continue; } colors.Add(pixelArt[x, y]); } } colorsId = colors.Distinct().ToList(); minusColor = new List <int>(); for (int i = 0; i != colorsId.Count; i++) { ColorStat go = Instantiate(viewPrefab, scrollViewCubes).GetComponent <ColorStat>(); go.selfColor = colorsId[i]; int colorsToColor = colors.FindAll(x => x == colorsId[i]).Count; int nowHave = PlayerPrefs.GetInt(colorsId[i].ToString()); minusColor.Add(colorsToColor); if (nowHave < colorsToColor) { canColor = false; } go.selfString = $"{nowHave}/{colorsToColor}"; } }
private void Awake() { Instance = this; colors = new List <Color>(); Color[,] pixelArt = DataController.ReadImageByPixels(PlayerPrefs.GetString("CurrentArt"), out cameraPos, out cameraSize); for (int x = 0; x != pixelArt.GetLongLength(0); x++) { for (int y = 0; y != pixelArt.GetLongLength(1); y++) { if (pixelArt[x, y] == Color.clear) { continue; } Instantiate(cubePrefab, new Vector3(x, y, 0), Quaternion.identity).GetComponent <CubeController>().selfColor = pixelArt[x, y]; colors.Add(pixelArt[x, y]); } } constCubeCount = cubeCount = colors.Count; colors = colors.Distinct().ToList(); }