added HoverIndicator (geht ned ganz)
This commit is contained in:
parent
7ccf683005
commit
74941ea9ae
3 changed files with 107 additions and 3 deletions
|
|
@ -1,13 +1,17 @@
|
|||
using System;
|
||||
using Tiles;
|
||||
using UnityEngine;
|
||||
|
||||
public class TileBehaviour : MonoBehaviour
|
||||
{
|
||||
private BaseTile _tile;
|
||||
private SpriteRenderer _hoverIndicatorSpriteRenderer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_hoverIndicatorSpriteRenderer = gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
||||
SetHoverIndicatorVisibility(false);
|
||||
SetTile(new GrassTile());
|
||||
|
||||
HouseController.NewDayEvent.AddListener(_tile.DayLightStep);
|
||||
|
|
@ -40,7 +44,23 @@ public class TileBehaviour : MonoBehaviour
|
|||
void SetTile(BaseTile tileToSet)
|
||||
{
|
||||
_tile = tileToSet;
|
||||
Debug.Log(_tile.Sprite);
|
||||
GetComponent<SpriteRenderer>().sprite = _tile.Sprite;
|
||||
}
|
||||
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
Debug.Log("rein");
|
||||
SetHoverIndicatorVisibility(true);
|
||||
}
|
||||
|
||||
private void OnMouseExit()
|
||||
{
|
||||
Debug.Log("raus");
|
||||
SetHoverIndicatorVisibility(false);
|
||||
}
|
||||
|
||||
private void SetHoverIndicatorVisibility(bool visible)
|
||||
{
|
||||
_hoverIndicatorSpriteRenderer.enabled = visible;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ namespace Tiles
|
|||
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