See, it's working now (Tile sprites)
This commit is contained in:
parent
29de95f46a
commit
0288e90c78
11 changed files with 38 additions and 89 deletions
|
|
@ -1,17 +1,17 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Tiles
|
||||
{
|
||||
public abstract class BaseTile
|
||||
{
|
||||
protected Color color;
|
||||
public Color getColor => color;
|
||||
// TODO: Change to Sprite, also in subclasses
|
||||
// public Sprite sprite;
|
||||
|
||||
protected BaseTile(Color color)
|
||||
private Sprite _sprite;
|
||||
public Sprite Sprite => _sprite;
|
||||
|
||||
protected BaseTile(String pathToImageFile)
|
||||
{
|
||||
this.color = color;
|
||||
this._sprite = GenerateSpriteFromFile(pathToImageFile);
|
||||
}
|
||||
|
||||
protected void Start()
|
||||
|
|
@ -34,11 +34,16 @@ namespace Tiles
|
|||
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
static protected Sprite GenerateSpriteFromFile()
|
||||
|
||||
static protected Sprite GenerateSpriteFromFile(String pathToImageFile)
|
||||
{
|
||||
|
||||
byte[] data = System.IO.File.ReadAllBytes(pathToImageFile);
|
||||
Texture2D texture = new Texture2D(32, 32, TextureFormat.ARGB32, false);
|
||||
texture.LoadImage(data);
|
||||
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 32);
|
||||
Debug.Log(sprite);
|
||||
return sprite;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue