So, I had an idea for making a game that include characters customization, and I want to make user can actually change the character’s body color. But, I have a problem in here. When I drag the sprite that I want to render, it is just gone. This is the picture of it :
[125502-capture.png*|125502]][1]][1]
Here is how the spriteRenderer object looks like :
[125505-captured.png*|125505]
But in the gameplay, the body doesn’t show up, it’s just the other sprite that showed up!
This is the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class skinColor : MonoBehaviour {
public GameObject panel;
public SpriteRenderer body;
public Color[] colors;
public int whatColor = 1;
void Update()
{
for(int i=0; i<colors.Length; i++)
{
if(i == whatColor)
{
body.color = colors*;*
}
}
}
public void ChangePanelState(bool state)
{
panel.SetActive(state);
}
public void ChangeBodyColor(int index)
{
whatColor = index;
}
}