Question by
djremiks · Sep 07, 2017 at 12:38 PM ·
arrayspritegetcomponentspriterenderer
SpriteRenderer.sprite change from Sprite array is not working
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];
}
}
Comment
Best Answer
Answer by djremiks · Sep 14, 2017 at 09:56 AM
My component targeting was not good : problem solved
Your answer
Follow this Question
Related Questions
Stencil Buffer not working with SpriteMask 0 Answers
Cycling through array not working. Pulling my hair over this one. 0 Answers
How do you access the Scripts, Functions, and Bools within an array of GameObjects? 0 Answers
creating a 2d peeling system in unity 0 Answers
update sprites for multiple similar objects. Need help 1 Answer