private Texture2D GetTexture(Sprite sprite) { if (sprite == null) { return(null); } if (spritesToTextures.ContainsKey(sprite)) { return(spritesToTextures[sprite]); } var texture = EditorUtilites.FetchTexture(sprite); spritesToTextures.Add(sprite, texture); return(texture); }
private void OnEnable() { var prefabs = Resources.LoadAll <GameObject>(Constants.AttachmentsFolder); attachmentNames = prefabs.Select(prefab => prefab.name).ToArray(); sprites = new Sprite[prefabs.Length]; for (int i = 0; i < prefabs.Length; i++) { sprites[i] = prefabs[i].HasComponent <MMKCore.TokenComponents.Graphics>() ? prefabs[i].GetComponent <MMKCore.TokenComponents.Graphics>().Sprite : null; if (sprites[i] != null) { spritesToTextures[sprites[i]] = EditorUtilites.FetchTexture(sprites[i]); } } EditorApplication.update += Track; }