Please help me to made this script work.
The SpriteRenderer get component does not work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mapTypeScript : MonoBehaviour
{
public mapEventType mapEventType;
// Ihave put the 15 sprite on the array...
public Sprite[] mapTypeSprites = new Sprite[15];
private Sprite SpriteRendererRoof;
// Use this for initialization
void Start()
{
//This is not working
SpriteRendererRoof = this.transform.parent.GetChild(0).GetComponent<SpriteRenderer>().sprite as Sprite;
if(SpriteRendererRoof == !null)
{
Debug.Log("This is work");
}
// this is not working too
SpriteRendererRoof = mapTypeSprites[5];
}
}