private void Start() { _buttonPosition = transform.position; var sprites = new Sprite[_gamePadsAtlas.spriteCount]; _gamePadsAtlas.GetSprites(sprites); var usedNumbers = new List <int>(); for (int j = 0; j < Lines; j++) { for (int i = 0; i < Columns; i++) { var button = Instantiate(_memoryButtonGo, _buttonPosition, Quaternion.identity, transform); var randomNumber = GetRandomNumber(sprites, usedNumbers); button.Renderer.sprite = sprites[randomNumber]; button.PreInit(this, randomNumber); _memoryButtons.Add(button); _buttonPosition.x += HorizontalSpace; } _buttonPosition.z += VerticalSpace; _buttonPosition.x = transform.position.x; } }
private void Start() { sprites = new Sprite[spriteAtlas.spriteCount]; Array.Reverse(sprites); spriteAtlas.GetSprites(sprites); ConvertStringToSprites(stringToShow); }
IEnumerator RequestProfileIconCoro(string email) { using (UnityWebRequest www = UnityWebRequest.Post(WebReq.serverUrl + "profile/viewAll", new WWWForm())) { byte[] ReqJson = System.Text.Encoding.UTF8.GetBytes(JsonUtility.ToJson(new ProfileReqJson(email))); www.uploadHandler = new UploadHandlerRaw(ReqJson); www.SetRequestHeader("Content-Type", "application/json"); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { ProfileResJson res = JsonUtility.FromJson <ProfileResJson>(www.downloadHandler.text); Sprite[] icons = new Sprite[spriteAtlas.spriteCount]; spriteAtlas.GetSprites(icons); iconButton.GetComponentInChildren <Image>().sprite = icons[res.icon]; iconButton.GetComponent <Button>().enabled = true; } } }
public static void LoadSpriteAtlas() { string atlasPath = "Assets/Resources/Sprite/Atlas/"; string[] atlasFileList = Directory.GetFiles(atlasPath, "*.spriteatlas", SearchOption.AllDirectories); System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < atlasFileList.Length; i++) { string filePath = atlasFileList[i]; SpriteAtlas spriteAtlas = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(filePath); int spriteCount = spriteAtlas.spriteCount; Sprite[] spriteArray = new Sprite[spriteCount]; spriteAtlas.GetSprites(spriteArray); string atlasAssetPath = AssetDatabase.GetAssetPath(spriteAtlas); for (int j = 0; j < spriteArray.Length; j++) { string spriteAssetPath = AssetDatabase.GetAssetPath(spriteArray[j].texture); sb.Append(spriteAssetPath); sb.Append(":"); sb.Append(atlasAssetPath); sb.Append("\n"); } } StreamWriter writer = new StreamWriter(SpriteAtlasMapPath, false); writer.Write(sb.ToString()); writer.Close(); }
private static void PopulateSpriteTables(SpriteAtlas spriteAtlas, ref List <TMP_SpriteCharacter> spriteCharacterTable, ref List <TMP_SpriteGlyph> spriteGlyphTable) { // Get number of sprites contained in the sprite atlas. int spriteCount = spriteAtlas.spriteCount; Sprite[] sprites = new Sprite[spriteCount]; // Get all the sprites spriteAtlas.GetSprites(sprites); for (int i = 0; i < sprites.Length; i++) { Sprite sprite = sprites[i]; TMP_SpriteGlyph spriteGlyph = new TMP_SpriteGlyph(); spriteGlyph.index = (uint)i; spriteGlyph.metrics = new GlyphMetrics(sprite.textureRect.width, sprite.textureRect.height, -sprite.pivot.x, sprite.textureRect.height - sprite.pivot.y, sprite.textureRect.width); spriteGlyph.glyphRect = new GlyphRect(sprite.textureRect); spriteGlyph.scale = 1.0f; spriteGlyph.sprite = sprite; spriteGlyphTable.Add(spriteGlyph); TMP_SpriteCharacter spriteCharacter = new TMP_SpriteCharacter(0xFFFE, spriteGlyph); spriteCharacter.name = sprite.name; spriteCharacter.scale = 1.0f; spriteCharacterTable.Add(spriteCharacter); } }
private static void SaveSpriteGUID(string atlasPath) { SpriteAtlas sa = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(atlasPath); if (sa != null) { string atlasName = Path.GetFileNameWithoutExtension(atlasPath); string[] list = atlasName.Split('-'); int size = list.Length; if (size < 3) { return; } StringBuilder sb = new StringBuilder(); sb.Append(list[size - 4]).Append('-').Append(list[size - 3]).Append('-').Append(list[size - 1]); string shortName = sb.ToString(); Sprite[] sps = new Sprite[sa.spriteCount]; int ret = sa.GetSprites(sps); for (int i = 0; i < sps.Length; i++) { Sprite item = sps[i]; string spPath = AssetDatabase.GetAssetPath(item.texture); string guid = AssetDatabase.AssetPathToGUID(spPath); _CachedAtlasSpriteGUID[guid] = shortName; _CachedAtlasPath[guid] = atlasPath; } } }
public static Sprite[] GetPartSprites(PawnPart part, string groupName) { string resourceName = $"{part} Sprites"; Sprite[] values = new Sprite[4]; SpriteAtlas atlas = (SpriteAtlas)Get.m_Resources[ResourceType.Sprites].First(x => x.name.Equals(resourceName)); Sprite[] sprites = new Sprite[atlas.spriteCount]; atlas.GetSprites(sprites); sprites = System.Array.FindAll(sprites, x => x.name.Contains(groupName)); for (int i = 0; i < values.Length; ++i) { PawnDirection dir = (PawnDirection)i; #if UNITY_EDITOR string str = $"{dir}(Clone)"; #else string str = dir.ToString(); #endif var value = sprites.FirstOrDefault(x => x.name.EndsWith(str, System.StringComparison.OrdinalIgnoreCase)); values[i] = value; } return(values); }
private static void SpriteNameSelector(SerializedProperty property, SpriteAtlas atlas) { var menu = new GenericMenu(); var spritesCount = atlas.spriteCount; var sprites = new Sprite[spritesCount]; atlas.GetSprites(sprites); foreach (var sprite in sprites) { var name = sprite.name; if (name.EndsWith(SpriteNameSuffix)) { name = name.Remove(name.Length - SpriteNameSuffix.Length); } // While sprite atlas supports sprites with duplicate names, GenericMenu does not, // so it will display only one items for all sprites with duplicate name. menu.AddItem(new GUIContent(name), name == property.stringValue, StringPropertyPair.HandlePairObjectSelect, new StringPropertyPair(name, property)); } menu.ShowAsContext(); }
private TileRegistry() { treeTiles = new List <Tile>(); palmTiles = new List <Tile>(); rockBeachTiles = new List <Tile>(); rockTiles = new List <Tile>(); allTiles = new Dictionary <String, Tile>(); allSprites = new Dictionary <String, Sprite>(); SpriteAtlas spriteAtlas = Resources.Load <SpriteAtlas>("SpriteAtlas"); Sprite[] sprites = new Sprite[spriteAtlas.spriteCount]; spriteAtlas.GetSprites(sprites); foreach (Sprite sprite in sprites) { Tile tile = ScriptableObject.CreateInstance <Tile>(); tile.sprite = sprite; allTiles[sprite.name.Substring(0, sprite.name.Length - 7)] = tile; allSprites[sprite.name.Substring(0, sprite.name.Length - 7)] = sprite; } treeTiles.Add(allTiles["Overworld_Tileset_253"]); treeTiles.Add(allTiles["Overworld_Tileset_286"]); palmTiles.Add(allTiles["TropicalExtras_Tree_Beach_0"]); palmTiles.Add(allTiles["TropicalExtras_Tree_Beach_1"]); palmTiles.Add(allTiles["TropicalExtras_Tree_Beach_2"]); rockTiles.Add(allTiles["TropicalExtras_Rock_0"]); rockTiles.Add(allTiles["TropicalExtras_Rock_1"]); rockBeachTiles.Add(allTiles["TropicalExtras_Rock_Beach_0"]); rockBeachTiles.Add(allTiles["TropicalExtras_Rock_Beach_1"]); }
/// <summary> /// スプライトの配列を返します /// </summary> public static Sprite[] GetSprites(this SpriteAtlas self) { var sprites = new Sprite[self.spriteCount]; self.GetSprites(sprites); return(sprites); }
public void setupBackgroundImg() { int level = SDGameManager.Instance.currentLevel; // int s = level / SDConstants.LevelNumPerSection; string nb; if (s == 0) { nb = "land"; } else if (s == 1) { nb = "sea"; } else { nb = "land"; } if (currentLevelTheme != nb) { currentLevelTheme = nb; // SpriteAtlas atlas = SDDataManager.Instance.atlas_battleBg; Sprite[] all = new Sprite[0]; atlas.GetSprites(all); List <Sprite> matchs = all.ToList().FindAll(x => x.name.Contains(currentLevelTheme)); backgroundSps = matchs; } if (backgroundSps.Count > 0) { backgroundImg.sprite = backgroundSps[UnityEngine.Random .Range(0, backgroundSps.Count)]; } }
public AtlasLoader(SpriteAtlas atlas) { m_AtlasName = atlas.name; Sprite[] allsprites = new Sprite[atlas.spriteCount]; atlas.GetSprites(allsprites); allsprites.Traversal((Sprite sprite) => { string name = sprite.name.Replace("(Clone)", ""); m_SpriteDic.Add(name, sprite); }); }
// VOID AWAKE================================================================ void Awake() { var spritesInAtlas = new Sprite[atlas.spriteCount]; atlas.GetSprites(spritesInAtlas); spriteList = spritesInAtlas.ToList(); }
void Start() { _uiController = UIController.Instance; _ninjaSet = new Sprite[ninjaAtlas.spriteCount]; ninjaAtlas.GetSprites(_ninjaSet); _shotTimer = 0f; _shurikenNum = GameManager.Instance.shurikensMag; _spriteBody = gameObject.transform.GetChild(1).GetComponent <SpriteRenderer>(); }
void Start() { Wall_atlas = Resources.Load <SpriteAtlas>("Dungeon\\Walls_Atlas"); sprite_count = Wall_atlas.spriteCount; sprite_array = new Sprite[sprite_count]; Wall_atlas.GetSprites(sprite_array); var enemy_status = gameObject.GetComponent <Enemy_Controller>().enemy_status; var actor_manager = Actor_Manager.Instance; }
public void setCharDataList(int spriteNumber) { var sprites = new Sprite[spriteAtlas.spriteCount]; spriteAtlas.GetSprites(sprites); spriteList = sprites.ToList(); imageRenderer.sprite = spriteList[spriteNumber]; }
private void Awake() { atlas = Resources.Load(path, typeof(SpriteAtlas)) as SpriteAtlas; Debug.Log(atlas.name); cardSprites = new Sprite[atlas.spriteCount]; atlas.GetSprites(cardSprites); // cardSprites = Resources.LoadAll(path, typeof(Sprite)).Cast<Sprite>().ToList(); cardLibray = new List <int>(); }
private void Awake() { if (readFromAtlas) { sprites = new Sprite[atlas.spriteCount]; atlas.GetSprites(sprites); Array.Sort(sprites, (s1, s2) => string.Compare(s1.name, s2.name, StringComparison.Ordinal)); } }
public Sprite[] GetHeroSprites() { if (heroSprites == null) { heroSprites = new Sprite[heroesSpriteAtlas.spriteCount]; heroesSpriteAtlas.GetSprites(heroSprites); } return(heroSprites); }
/// <summary> /// 스프라이트 배열을 세팅한다. /// </summary> void SetSpritesArray(bool _forced = false) { //지금 그리고 있는 아틀라스가 없거나 다른경우에 해당 아틀라스에서 스프라이트들을 얻는다. if (_forced == true || drawAtlas == null || drawAtlas != curAtlas) { drawAtlas = curAtlas; arrSprites = new Sprite[curAtlas.spriteCount]; curAtlas.GetSprites(arrSprites); } }
// Use this for initialization void Start() { var lightArray = new Sprite[lights.spriteCount]; lights.GetSprites(lightArray); _renderer = GetComponent <Image>(); color = GetColorFromSpriteName(_renderer.sprite.name); //SetSprite(0, true); ShipInternals.Instance.RegisterInstrumentLight(this); }
/// <summary> /// Return the Sprite name array in this atlas.(Jpn.アトラス内のSprite名の配列を返す.) /// </summary> public static string[] GetSpriteNames(this SpriteAtlas aSelf) { Sprite[] spriteArray = new Sprite[aSelf.spriteCount]; aSelf.GetSprites(spriteArray); string[] nameArray = new string[aSelf.spriteCount]; for (var idx = 0; idx < aSelf.spriteCount; ++idx) { nameArray[idx] = spriteArray[idx].name.Replace("(Clone)", ""); } return(nameArray); }
// Use this for initialization void Start() { //通过Resources来load _resAtlas = Resources.Load <SpriteAtlas>("ResAtlas"); //拿到atlas所有的sprite _carSprites = new Sprite[_carAtlas.spriteCount]; _carAtlas.GetSprites(_carSprites); StartCoroutine(RandomDisply()); }
void Start() { _sprites = new Sprite[decorAtlas.spriteCount]; decorAtlas.GetSprites(_sprites); _camera = Camera.main; _startY = _camera.ViewportToWorldPoint(new Vector3(1, 1, 0)).y + 2; _minX = _camera.ViewportToWorldPoint(new Vector3(0, 0, 0)).x + 1; _maxX = _camera.ViewportToWorldPoint(new Vector3(1, 1, 0)).x - 1; timer = 2f; }
/// <summary> /// SpriteAtlas のテクスチャのメモリサイズを取得。 /// 中身の Sprite の texture を見ることで無理やり取得している。 /// そのため現状の実装は 1 枚にパッキングされている前提(複数枚のアトラスは未対応) /// <summary> long GetSpriteAtlasTextureMemory(SpriteAtlas atlas) { if (atlas.spriteCount == 0) { return(0); } Sprite[] sprites = new Sprite[atlas.spriteCount]; atlas.GetSprites(sprites); return(Profiler.GetRuntimeMemorySizeLong(sprites[0].texture)); }
void Start() { enemy_atlas = Resources.Load <SpriteAtlas>("Enemy_Atlas"); sprite_count = enemy_atlas.spriteCount; sprite_array = new Sprite[sprite_count]; enemy_atlas.GetSprites(sprite_array); var enemy_status = gameObject.GetComponent <Enemy_Controller>().enemy_status; var actor_manager = Actor_Manager.Instance; Set_Sprite(enemy_status.ID); }
// Use this for initialization void Start() { sprits = new Sprite[spr.spriteCount]; spr.GetSprites(sprits); ren.sprite = sprits[current]; timeStamp = Time.time + 1f; sheets = new Animator2D.SpriteSheet[1] { new Animator2D.SpriteSheet(CreateSpriteSheet("Blue", sprits), 1f) }; }
public void initCardStyle(Card[] cards) { CardFront = new Sprite[Fronts.spriteCount]; Fronts.GetSprites(CardFront); CardBack = Fronts.GetSprite("back"); for (int i = 0; i < cards.Length; i++) { cards[i].mBackSprite = CardBack; cards[i].mFrontSprite = CardFront[cards[i].mNum]; cards[i].SetSprite(); } }
static IEnumerable <Sprite> GetAllSprite(SpriteAtlas spriteAtlas) { //spriteの空の配列を作成、サイズはAtlasに含まれるSpriteの数 Sprite[] spriteArray = new Sprite[spriteAtlas.spriteCount]; //spriteArrayに全Spriteを設定 spriteAtlas.GetSprites(spriteArray); foreach (var sprite in spriteArray) { yield return(sprite); } }
public static IEnumerable <Sprite> GetAllSprites(this SpriteAtlas spriteAtlas) { var sprites = new Sprite[spriteAtlas.spriteCount]; spriteAtlas.GetSprites(sprites); foreach (var sprite in sprites) { sprite.name = sprite.name.Replace("(Clone)", ""); } return(sprites); }